In the rails code I came across following method definition def initialize(*)
I understand what def foo(*a)
means but can't figure out significance of omitting identifier name after *
. How do you access any arguments passed to this method?
In the rails code I came across following method definition def initialize(*)
I understand what def foo(*a)
means but can't figure out significance of omitting identifier name after *
. How do you access any arguments passed to this method?
Here's my guess.
It works because of second line:
def initialize(*)
super
...
end
So the method receives arbitrary number of arguments and passes all of them to super
(as you know, super
without arguments means take all arguments from original method).
And then in this case the names for arguments are not required.