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

RSS Icon Subscribe to comments

You need to login to post a comment.