Skip to content

Instantly share code, notes, and snippets.

@niku
Created May 2, 2011 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niku/951257 to your computer and use it in GitHub Desktop.
Save niku/951257 to your computer and use it in GitHub Desktop.
difference of block parameter
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