[ACCEPTED]-Given an array of arguments, how do I send those arguments to a particular function in Ruby?-arguments
Accepted answer
As you know, when you define a method, you 5 can use the *
to turn a list of arguments 4 into an array. Similarly when you call a 3 method you can use the *
to turn an array 2 into a list of arguments. So in your example 1 you can just do:
Ilike.new.turtles(*a)
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.