3 ms·
If we are going to golf, here is a small Perl6 version: sub print-maybe ( $_ ) { say $_ // "nothing" } Or to translate your code: my &print
by b2gills 8y ago
If we are going to golf, here is a small Perl6 version:
sub print-maybe ( $_ ) {
say $_ // "nothing"
}
Or to translate your code:
my &print-maybe = { say $_ // "nothing" }
Of course both of the above take advantage of all Perl6 types being Maybe types already.
(Think of defined-or `//` as having a slightly different slant to it than `||`.)