in reply to [Perl 6] Generalized shortcutting C<||>?
Call it thus:sub cond (&$$) { (my $check, local $_, my $default) = @_; $check->() ? $_ : $default; }
It's the sort of trivial function that might be at home in List::MoreUtils.print cond { fileno($_} } $fh, 'undef';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [Perl 6] Generalized shortcutting C<||>?
by blazar (Canon) on Sep 18, 2007 at 13:52 UTC |