This project is archived and is in readonly mode.
reverse_merge!() modifies the hash outside the method scope
-
Mike Breen
- Assigned user set to Ryan Bigg
Ruby passes params by reference not by value so I'm not sure why we would expect Rails to behave differently.
What you probably want to do here is to use the non-bang version.
def some_method(options = {}) default_options = { :attr1 => "default string", :attr2 => "another string" } my_options = options.reverse_merge(default_options) puts "*** options INSIDE the method call :" puts my_options.inspect end -
Jérémy Lecour
I also agree with Mike. I guess I misinterpreted something. Sorry about that.