看板 Ruby 關於我們 聯絡資訊
偶然忘了打函式只打了小括號 發現.()等同.call() ->(){print "hello, world"}.() #=>hello, world ->(){print "hello, world"}.call() #=>hello, world 不只是Proc 其他物件只要有call這個方法都可以這樣用 class C def call print "hello, world" end end C.new.() #=>hello, world 這誰會發現啊... 而且可讀性也不好... -- CPU: Athlon XP 1800+ RAM: DDR400 1GB+256MB MB: A7S266U2-VM/U2 VGA: SiS650 硬碟:IDE 40G*3 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.122.185.201 ※ 文章網址: http://www.ptt.cc/bbs/Ruby/M.1402547180.A.F57.html