Created
June 29, 2011 07:19
-
-
Save brixen/1053318 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sasha:rubinius2.0 brian$ irb | |
ruby-1.9.2-p180 :001 > def m | |
ruby-1.9.2-p180 :002?> yield [1,2,3] | |
ruby-1.9.2-p180 :003?> end | |
=> nil | |
ruby-1.9.2-p180 :004 > m { |a, b| p a, b } | |
1 | |
2 | |
=> [1, 2] | |
ruby-1.9.2-p180 :005 > m { |a| p a } | |
[1, 2, 3] | |
=> [1, 2, 3] | |
ruby-1.9.2-p180 :006 > def n | |
ruby-1.9.2-p180 :007?> yield 1, 2, 3 | |
ruby-1.9.2-p180 :008?> end | |
=> nil | |
ruby-1.9.2-p180 :009 > n { |a| p a } | |
1 | |
=> 1 | |
ruby-1.9.2-p180 :010 > l = ->(a,b) { p a, b } | |
=> #<Proc:0x000001009cfd50@(irb):10 (lambda)> | |
ruby-1.9.2-p180 :011 > m(&l) | |
ArgumentError: wrong number of arguments (1 for 2) | |
from (irb):10:in `block in irb_binding' | |
from (irb):2:in `m' | |
from (irb):11 | |
from /Users/brian/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>' | |
ruby-1.9.2-p180 :012 > n(&l) | |
ArgumentError: wrong number of arguments (3 for 2) | |
from (irb):10:in `block in irb_binding' | |
from (irb):7:in `n' | |
from (irb):12 | |
from /Users/brian/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>' | |
ruby-1.9.2-p180 :013 > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment