我试过这个,但它不起作用。
def n_times(thing)
lambda {|n| thing * n }
end
def other(counter,thing)
com = counter(thing)
return com
end
com = other(n_times,10)
com.call("what ")
错误 :
test.rb:1:in `n_times': wrong number of arguments (0 for 1) (ArgumentError)
from test.rb:10:in `<main>'