Hi guys,

I'm wondering what the preferred method of parsing the "options" hash is?

In one file, I've just seen these three different methods:

def foobar(options = {})
  options.reverse_merge!(:length => 30)
  #...
  call_another_method(options[:length])
end

def foobar(options = {})
  options[:length] ||= 30
  #...  
  call_another_method(options[:length])
end

def foobar(options = {})
  length = options[:length] || 30
  #...
  call_another_method(length)
end

I'd like to go through and standardise them, at least in the files I'm 
working on. 

Which is the preferred method?

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/O10fcEudgi4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to