Passing a hash to a function ( *args ) and its meaning

Viewed 47453

When using an idiom such as:

def func(*args)
  # some code
end

What is the meaning of *args? Googling this specific question was pretty hard, and I couldn't find anything.

It seems all the arguments actually appear in args[0] so I find myself writing defensive code such as:

my_var = args[0].delete(:var_name) if args[0]

But I'm sure there's a better way I'm missing out on.

1 Answers
Related