Created
May 2, 2011 07:18
-
-
Save niku/951257 to your computer and use it in GitHub Desktop.
difference of block parameter
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
class Foo | |
def block | |
yield if block_given? | |
end | |
def call &b | |
b.call if b | |
end | |
end | |
Foo.new.send(:block) { 'block called' } # => "block called" | |
l = ->{ 'lambda called' } | |
Foo.new.send(:call) &l # => false | |
Foo.new.send(:call, &l) # => "lambda called" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment