Ruby Function with Unlimited Number of Parameters
Use *rest
. here's a nice little tutorial.
Use the splat operator *
def foo(a,b,c,*others)
# this function has at least three arguments,
# but might have more
puts a
puts b
puts c
puts others.join(',')
end
foo(1,2,3,4,5,6,7,8,9)
# prints:
# 1
# 2
# 3
# 4,5,6,7,8,9