In List§
See primary documentation in context for method Bool
method Bool(List: --> Bool)
Returns True
if the list has at least one element, and False
for the empty list.
say ().Bool; # OUTPUT: «False»say (1).Bool; # OUTPUT: «True»
In Capture§
See primary documentation in context for method Bool
method Bool(Capture: --> Bool)
Returns True
if the Capture
contains at least one named or one positional argument.
say \(1,2,3, apples => 2).Bool; # OUTPUT: «True»say \().Bool; # OUTPUT: «False»
In Failure§
See primary documentation in context for method Bool
multi method Bool(Failure: --> Bool)
Returns False
, and marks the failure as handled.
sub f() ;my = f;say .handled; # OUTPUT: «False»say .Bool; # OUTPUT: «False»say .handled; # OUTPUT: «True»
In Match§
See primary documentation in context for method Bool
method Bool(Capture: --> Bool)
Returns True
on successful and False
on unsuccessful matches. Please note that any zero-width match can also be successful.
say 'abc' ~~ /^/; # OUTPUT: «「」»say $/.from, ' ', $/.to, ' ', ?$/; # OUTPUT: «0 0 True»
In Regex§
See primary documentation in context for method Bool
multi method Bool(Regex: --> Bool)
Matches against the caller's $_ variable, and returns True
for a match or False
for no match.
In role Setty§
See primary documentation in context for method Bool
multi method Bool(Setty: --> Bool)
Returns True
if the invocant contains at least one element.
my = Set.new(1, 2, 3);say .Bool; # OUTPUT: «True»my = ∩ Set.new(4, 5); # set intersection operatorsay .Bool; # OUTPUT: «False»
In role Baggy§
See primary documentation in context for method Bool
method Bool(Baggy: --> Bool)
Returns True
if the invocant contains at least one element.
my = ('eggs' => 1).BagHash;say .Bool; # OUTPUT: «True»# (since we have one element)<eggs> = 0; # weight == 0 will lead to element removalsay .Bool; # OUTPUT: «False»
In StrDistance§
See primary documentation in context for method Bool
Returns True
if before
is different from after
.
In Proc§
See primary documentation in context for method Bool
multi method Bool(Proc:)
Awaits for the process to finish and returns True
if both exit code and signal of the process were 0, indicating a successful process termination. Returns False
otherwise.
In Mu§
See primary documentation in context for routine Bool
multi Bool(Mu --> Bool)multi method Bool( --> Bool)
Returns False
on the type object, and True
otherwise.
Many built-in types override this to be False
for empty collections, the empty string or numerical zeros
say Mu.Bool; # OUTPUT: «False»say Mu.new.Bool; # OUTPUT: «True»say [1, 2, 3].Bool; # OUTPUT: «True»say [].Bool; # OUTPUT: «False»say %( hash => 'full' ).Bool; # OUTPUT: «True»say .Bool; # OUTPUT: «False»say "".Bool; # OUTPUT: «False»say 0.Bool; # OUTPUT: «False»say 1.Bool; # OUTPUT: «True»say "0".Bool; # OUTPUT: «True»
In role Numeric§
See primary documentation in context for method Bool
multi method Bool(Numeric:)
Returns False
if the number is equivalent to zero, and True
otherwise.
In Map§
See primary documentation in context for method Bool
method Bool(Map: --> Bool)
Returns True
if the invocant contains at least one key/value pair.
my = Map.new('a' => 2, 'b' => 17);say .Bool; # OUTPUT: «True»
In Str§
See primary documentation in context for method Bool
method Bool(Str: --> Bool)
Returns False
if the string is empty, True
otherwise.
In Allomorph§
See primary documentation in context for method Bool
multi method Bool(::?CLASS:)
Returns False
if the invocant is numerically 0
, otherwise returns True
. The Str
value of the invocant is not considered.
Note: For the Allomorph
subclass RatStr
also see Rational.Bool
.
In Promise§
See primary documentation in context for method Bool
multi method Bool(Promise:)
Returns True
for a kept or broken promise, and False
for one in state Planned
.
In Junction§
See primary documentation in context for method Bool
multi method Bool(Junction:)
Collapses the Junction
and returns a single Boolean value according to the type and the values it holds. Every element is transformed to Bool
.
my = Junction.new( "one", 1..6 );say .Bool; # OUTPUT: «False»
All elements in this case are converted to True
, so it's false to assert that only one of them is.
my = Junction.new( "one", <0 1> );say .Bool; # OUTPUT: «True»
Just one of them is truish in this case, 1
, so the coercion to Bool
returns True
.
In role Rational§
See primary documentation in context for method Bool
multi method Bool(Rational: --> Bool)
Returns False
if numerator is 0
, otherwise returns True
. This applies for <0/0>
zero-denominator <Rational
as well, despite ?<0/0>.Num
being True
.
In role Blob§
See primary documentation in context for method Bool
multi method Bool(Blob:)
Returns False
if and only if the buffer is empty.
my = Blob.new();say .Bool; # OUTPUT: «False»= Blob.new([1, 2, 3]);say .Bool; # OUTPUT: «True»