Skip to content

Instantly share code, notes, and snippets.

@gfldex
Last active July 13, 2016 19:12
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/2b546491fbbfd15caa0ad3e4faab15e0 to your computer and use it in GitHub Desktop.
Save gfldex/2b546491fbbfd15caa0ad3e4faab15e0 to your computer and use it in GitHub Desktop.
class DefinedAlternationContainer {
has $.item;
has $.condition-was-defined;
}
multi sub infix:<?>(\a, \b -->DefinedAlternationContainer) is export {
with a { return DefinedAlternationContainer.new(item => b, condition-was-defined => True) }
DefinedAlternationContainer.new(item => Any, condition-was-defined => False)
}
multi sub infix:<!>(DefinedAlternationContainer:D \cont, \b) is export {
cont.condition-was-defined ?? cont.item !! b
}
my $falsish = 2 but False;
say $falsish ? 'defined' ! 'undefined';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment