Easy default options for methods in Ruby


 / Published in: Other
 

  1.  
  2. def my_method(opts={})
  3. {:arg_one => 'foo', :arg_two => 'two'}.merge(opts)
  4. end
  5.  

Report this snippet  

You need to login to post a comment.