Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # using 'keyword style' arguments
- def mymethod(required_arg, args={})
- do_fancy_stuff if args[:fancy]
- end
- mymethod "foo",:fancy => true # => args={:fancy => true}
- mymethod "foo" # => args={}
- # using * (splat) arguments
- def mymethod(required_arg, *args)
- # args is an array of extra args, maybe empty
- end
- mymethod "foo","bar",:fancy => true # => args=["bar",{:fancy=>true}]
- mymethod "foo" # => args=[]
Add Comment
Please, Sign In to add comment