nop*_*ole 2 ruby methods function
在Ruby中,如何在不调用函数的情况下引用函数,因为foo与foo()相同,因此它已被调用.
例如, puts.class 是一样的 puts().class
你这样使用method:
o = Object.new
def o.do_it
puts "I did it!"
end
m = o.method(:do_it)
m.call # prints out "I did it!"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
98 次 |
| 最近记录: |