Advertisement
Guest User

default arguments

a guest
Aug 15th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.18 KB | None | 0 0
  1. FOO_DEFAULTS = {
  2.   :i => 666,
  3.   :some_other_value => false,
  4. }.freeze
  5.  
  6. def foo(args)
  7.   v = FOO_DEFAULTS.merge(args)
  8.   @i = v[:i]
  9.   @some_other_value = v[:some_other_value]
  10. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement