Skip to content

Instantly share code, notes, and snippets.

@confiks
Created February 24, 2017 16:35
Show Gist options
  • Save confiks/44329da723edf36895da35db1877d864 to your computer and use it in GitHub Desktop.
Save confiks/44329da723edf36895da35db1877d864 to your computer and use it in GitHub Desktop.
2.3.1 :001 > def foo; end
=> :foo
2.3.1 :002 > def bar1(*args, **options); foo(*args, **options); end
=> :bar1
2.3.1 :003 > def bar2(*args, **options); args == [] && options == {}; end
=> :bar2
2.3.1 :004 > def bar3; foo(*[], **{}); end
=> :bar3
2.3.1 :005 > bar1
ArgumentError: wrong number of arguments (given 1, expected 0)
from (irb):1:in `foo'
from (irb):2:in `bar1'
from (irb):5
from /Users/peter/.rvm/rubies/ruby-2.3.1/bin/irb:11:in `<main>'
2.3.1 :006 > bar2
=> true
2.3.1 :007 > bar3
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment