3 ms·
Great article. One question: > There’s one final use for the splat ( * ); when overriding methods in a subclass and calling super. If it turns out you don’t ne
by losvedir 13y ago
Great article. One question:
> There’s one final use for the splat ( * ); when overriding methods in a subclass and calling super. If it turns out you don’t need the arguments to the method for whatever additional behaviour you’re adding, you can accept all arguments with a bare splat, then a bare super passes all arguments to super.
I thought that was the default behavior of super. Isn't it the case that a bare super by default passes all the method's original arguments? I know this has bit me in the past where I've been forced to call `super()` with empty parentheses explicitly to prevent this behavior.
- matsadler 13y agoYou're correct, that is the default behaviour of super. My intention wasn't to say that super only works like that when you've defined the method like `def foo( * )` but rather `def foo( * )` is an alternative to having to name your arguments when you're not even going to use them as they are automatically passed with bare super.
- losvedir 13y agoAh, yes, of course. I understand now. Skimmed a bit too fast there and misunderstood what you were getting at. Thanks!