Easy default options for methods in Ruby


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1.  
  2. def my_method(opts={})
  3. {:arg_one => 'foo', :arg_two => 'two'}.merge(opts)
  4. end
  5.  

Report this snippet


Comments


You need to login to view comments.