in reply to Re^2: Correct idiom for default parameters
in thread Correct idiom for default parameters
That looks pretty good!
And to answer your question in the post previous to this one, no I don't expect there to be an "undef" in the middle. The overwhelming majority of the cases there is one parameter that is optional. Which means that the predominant use will look like this:sub defaults { my ($self, $param) = map { @_ ? shift : $_ } (1); print($param); }
I found one place where it would be nice to have two optional parameters, but I'm debating refactoring that sub routine.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Correct idiom for default parameters
by LanX (Saint) on Apr 28, 2010 at 22:58 UTC |