Skip to content

Instantly share code, notes, and snippets.

@gfldex
Last active July 4, 2016 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfldex/02998dc3927426010d56092784b72152 to your computer and use it in GitHub Desktop.
Save gfldex/02998dc3927426010d56092784b72152 to your computer and use it in GitHub Desktop.
class DefinedAlternationContainer { has $.item; has $.condition-was-defined };
sub infix:<?//>(\a, \b -->DefinedAlternationContainer) { with a { return DefinedAlternationContainer.new(item => b, condition-was-defined => True) };
DefinedAlternationContainer.new(item => Any, condition-was-defined => False) };
sub infix:<!!>(DefinedAlternationContainer:D \cont, \b){ cont ?? cont.item !! b };
my $v = 2 but False;
dd $v ?// 2 !! 4;
$v = Any;
dd $v ?// 2 !! 4;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment