Skip to content

Instantly share code, notes, and snippets.

@twlz0ne
Last active August 29, 2015 14:00
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 twlz0ne/16fe38b5a3c5f28a76f1 to your computer and use it in GitHub Desktop.
Save twlz0ne/16fe38b5a3c5f28a76f1 to your computer and use it in GitHub Desktop.
最后一行不理解, &lambda {} 不是转成 block 了吗?
def foo(&block)
p block
end
foo #=> nil
foo("bar") #=> ArgumentError: wrong number of arguments (1 for 0)
foo {} #=> #<Proc:0x0000010123c998@(irb):6>
foo &lambda {} #=> #<Proc:0x0000010122c8e0@(irb):7 (lambda)>
foo(&lambda {}) #=> #<Proc:0x0000010120e980@(irb):8 (lambda)>
foo() {} #=> #<Proc:0x000001011fcd20@(irb):9>
foo() &lambda {} #=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment