In MuĀ§
See primary documentation in context for method not
method not()
Evaluates the item in Boolean context (leading to final evaluation of Junctions, for instance), and negates the result. It is the opposite of so
and its behavior is equivalent to the !
operator.
my @args = <-a -e -b>; my $verbose-selected = any(@args) eq '-v' | '-V'; if $verbose-selected.not { say "Verbose option not present in arguments"; } # OUTPUT: Ā«Verbose option not present in argumentsā¤Ā»
Since there is also a prefix version of not
, this example reads better as:
my @args = <-a -e -b>; my $verbose-selected = any(@args) eq '-v' | '-V'; if not $verbose-selected { say "Verbose option not present in arguments"; } # OUTPUT: Ā«Verbose option not present in argumentsā¤Ā»
In OperatorsĀ§
See primary documentation in context for prefix not
multi prefix:<not>(Mu $x --> Bool:D)
Evaluates its argument in Boolean context (and thus collapses Junction
s), and negates the result. Please note that not
is easy to misuse. See traps.