In Ruby, how do you refer to a function without invoking it, because foo is the same as foo() so it is already invoked.
for example, puts.class
is the same as puts().class
In Ruby, how do you refer to a function without invoking it, because foo is the same as foo() so it is already invoked.
for example, puts.class
is the same as puts().class
You use method
, like so:
o = Object.new
def o.do_it
puts "I did it!"
end
m = o.method(:do_it)
m.call # prints out "I did it!"