YAP6 Operator: The Default Operator
by Adriano Ferreira
Another article of the series "Yet Another Perl 6 Operator"
Among the new Perl 6 operators, there is the handy operator
'//', known as defined-or or the default operator. This novelty was anticipated by the introduction of this syntactic bit in Perl 5 (see the upcoming 5.10 release) — so you won't need to wait for Perl 6 to start using it.
print "arg: '", shift // "?", "'\\n";
$ perl dor.pl one
$ perl dor.pl ""
$ perl dor.pl
You probably intended to write "'\n" in the print statement on the third line of your first example, rather than "'n".
|@TomP Now it should be fixed. The weird thing is that I correctly wrote "'\n" but MT ate the backslash. So I double it and it worked.|
||| and && have corresponding low-precedence versions 'or' and 'and'. Will Perl 6 support 'dor'?|