How can I accomplish http://php.net/manual/en/function.call-user-func-array.php in ruby?
So I can do this:
class App
def foo(a,b)
puts a + b
end
def bar
args = [1,2]
App.send(:foo, args) # doesn't work
App.send(:foo, args[0], args[1]) # does work, but does开发者_如何学C not scale
end
end
Try exploding the array
App.send(:foo, *args)
精彩评论