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 not scale
end
end
Try exploding the array
App.send(:foo, *args)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With