possibilitybox
5/10/2006 5:25:00 AM
class IndexerHash
def new
@hash = Hash.new do |hash, input_key|
hash.each do |key, value|
return value if key.include? input_key
end
end
end
def [](key)
@hash[key]
end
def []=(key, value)
@hash[key]=value
end
def save
require "yaml"
output = YAML::dump(@hsh)
f = File.open('./index.yml', 'w')
f.write(output)
f.close
end
end
I get various errors related to what appears to be a malfunction of
Hash.new (but's probably me doing something wrong.). All of them raise
a NoMethodError for NilClass. (but hash isn't a Nil, is it?)
A hash created in an identical manner outside of IndexerHash.new works
as expected.
I'm using mac os x 10.4.6 on an macbook pro, irb 0.9.5 from
darwinports.
help!
(psst. if i didn't provide enough information, i'd be glad to provide
anything more that would help solving this problem.)