This question claims that you have use hacks like eval
to change a Hash
that was passed as a parameter. I expect this result:
def change_hash(hash)
hash[:non_existing_key] = :value
end
opts = {}
change_hash(opts)
opts # => {:non_existing_key => :value}
not to be possible since the Hash should be copied to the method by value. What is going on here?