prefixing the array with an asterisk : Variable Number Arguments « Method « Ruby






prefixing the array with an asterisk




array = ["there ", "AAA"]

def putter(first_word, second_word, third_word)
  puts first_word + " " + second_word + " " + third_word
end

putter "Hello ", *array

 








Related examples in the same category

1.Variable Arguments
2.Passing a Variable Number of Arguments
3.A variable number of arguments stored in an array.
4.Mixed parameters and varied length parameter