-
-
Save twlz0ne/16fe38b5a3c5f28a76f1 to your computer and use it in GitHub Desktop.
最后一行不理解, &lambda {} 不是转成 block 了吗?
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
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