I know what this means:
def f(*args) ... end
But what does this mean and why would you want to use it? Can it appear with named parameters, too?
def f(*) ... end
def f(*)
has the same effect as def f(*args)
, except that it does not name the globbed argument array. You might use it if you want the function to accept any number of arguments but don't actually need to refer to them within the function -- for example, if you are overriding a method but calling super
without passing an explicit argument list, which results in the original arguments being passed to super
.
You can write def f(a, b, *)
as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With