Provides a ?? !! equivalent that tests for definedness instread of trueness.
Switch branches/tags
Nothing to show
Latest commit f60a859 Jan 21, 2017 @gfldex META* -> META6.json
Failed to load latest commit information.
lib/Operator change operators to multis Jul 4, 2016
t git init Jul 4, 2016
.travis.yml add .travis.yml Jul 4, 2016
LICENSE Initial commit Jul 4, 2016 Revert "remove license to test for zef bug" Jan 19, 2017
META6.json META* -> META6.json Jan 21, 2017 add Jul 4, 2016


Build Status

Perl 6 provides control statements and operators to test for definedness instead of trueness, to provide ease of typing and a clear statement of intend from the programmer. Sadly there is currently no way to define your own ternary operators with Rakudo. However, we can emulate operators with 3 arguments with a chain of 2 infix operators, as long as we provide a type for the 2nd infix to handle dispatch properly.


use v6;
use Operator::defined-alternation;

my $falsish = 2 but False;
say $falsish ?// 'defined' !! 'undefined';
# OUTPUT: defined
# What is equivalent to:
say $falsish.defined ?? 'defined' !! 'undefined'; 
# OUTPUT: defined
# But opposed to:
say $falsish ?? 'true' !! 'false'; 
# OUTPUT: false 


(c) Wenzel P. P. Peppmeyer, Released under Artistic License 2.0.