in reply to Re^2: [Perl 6] Generalized shortcutting C<||>?
in thread [Perl 6] Generalized shortcutting C<||>?
I suspect Perl6 would make it more appetizing.sub cop { local $_ = shift; my ($cond, $default) = @_; $cond->() ? $_ : $default->(); } for my $test (2..4) { print "$test: ", cop($test, sub {$_ == 3}, sub { 'This is a default' + }), "\n"; }
|
|---|