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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
def f(*)has the same effect asdef 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 callingsuperwithout passing an explicit argument list, which results in the original arguments being passed tosuper.You can write
def f(a, b, *)as well.