Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
proc_obj = -> proto { print proto; puts("World")} puts proc_obj["Hi"] puts proc_obj.call("Hello") #Is this is the same as above
请让我参考一些链接来揭开这个神秘面纱......
该 lambda 发生的事情是您正在调用它的[]方法,这会导致 lambda 使用参数执行"Hi"。是call的,调用与调用相同[]。
[]
"Hi"
call
http://www.ruby-doc.org/core-1.9.3/Proc.html#method-i-5B-5D