Passing a Variable Number of Arguments : Variable Number Arguments « Method « Ruby






Passing a Variable Number of Arguments


def putter(first_word, *others)
  puts first_word + " " + others.join(" ")
end

putter "Hello", "from", "Ruby."

 








Related examples in the same category

1.Variable Arguments
2.prefixing the array with an asterisk
3.A variable number of arguments stored in an array.
4.Mixed parameters and varied length parameter