txt: ## bool.md
  Bool
  
  Combined from primary sources listed below.
  
  # [In Match](#___top "go to top of document")[§](#(Match)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Match#method_Bool)
  for **method Bool**.
  
  ```raku
  method Bool(Capture:D: --> Bool:D)
  ```
  
  Returns `True` on successful and `False` on unsuccessful matches. Please note that any zero-width match can also be successful.
  
  ```raku
  say 'abc' ~~ /^/;                   # OUTPUT: «｢｣␤»
  say $/.from, ' ',  $/.to, ' ', ?$/; # OUTPUT: «0 0 True␤»
  ```
  
  # [In role Baggy](#___top "go to top of document")[§](#(role_Baggy)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Baggy#method_Bool)
  for **method Bool**.
  
  ```raku
  method Bool(Baggy:D: --> Bool:D)
  ```
  
  Returns `True` if the invocant contains at least one element.
  
  ```raku
  my $breakfast = ('eggs' => 1).BagHash;
  say $breakfast.Bool;                              # OUTPUT: «True␤»
                                                    # (since we have one element)
  $breakfast<eggs> = 0;                             # weight == 0 will lead to element removal
  say $breakfast.Bool;                              # OUTPUT: «False␤»
  ```
  
  # [In StrDistance](#___top "go to top of document")[§](#(StrDistance)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/StrDistance#method_Bool)
  for **method Bool**.
  
  Returns `True` if `before` is different from `after`.
  
  # [In role Numeric](#___top "go to top of document")[§](#(role_Numeric)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Numeric#method_Bool)
  for **method Bool**.
  
  ```raku
  multi method Bool(Numeric:D:)
  ```
  
  Returns `False` if the number is equivalent to zero, and `True` otherwise.
  
  # [In Mu](#___top "go to top of document")[§](#(Mu)_routine_Bool "direct link")
  
  See primary documentation
  [in context](/type/Mu#routine_Bool)
  for **routine Bool**.
  
  ```raku
  multi        Bool(Mu --> Bool:D)
  multi method Bool(   --> Bool:D)
  ```
  
  Returns `False` on the type object, and `True` otherwise.
  
  Many built-in types override this to be `False` for empty collections, the empty [string](/type/Str) or numerical zeros
  
  ```raku
  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 Blob](#___top "go to top of document")[§](#(role_Blob)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Blob#method_Bool)
  for **method Bool**.
  
  ```raku
  multi method Bool(Blob:D:)
  ```
  
  Returns `False` if and only if the buffer is empty.
  
  ```raku
  my $blob = Blob.new();
  say $blob.Bool; # OUTPUT: «False␤»
  $blob = Blob.new([1, 2, 3]);
  say $blob.Bool; # OUTPUT: «True␤»
  ```
  
  # [In role Rational](#___top "go to top of document")[§](#(role_Rational)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Rational#method_Bool)
  for **method Bool**.
  
  ```raku
  multi method Bool(Rational:D: --> Bool:D)
  ```
  
  Returns `False` if [numerator](/routine/numerator) is `0`, otherwise returns `True`. This applies for `<0/0>` zero-denominator <`Rational` as well, despite `?<0/0>.Num` being `True`.
  
  # [In List](#___top "go to top of document")[§](#(List)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/List#method_Bool)
  for **method Bool**.
  
  ```raku
  method Bool(List:D: --> Bool:D)
  ```
  
  Returns `True` if the list has at least one element, and `False` for the empty list.
  
  ```raku
  say ().Bool;  # OUTPUT: «False␤»
  say (1).Bool; # OUTPUT: «True␤»
  ```
  
  # [In Junction](#___top "go to top of document")[§](#(Junction)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Junction#method_Bool)
  for **method Bool**.
  
  ```raku
  multi method Bool(Junction:D:)
  ```
  
  Collapses the `Junction` and returns a single Boolean value according to the type and the values it holds. Every element is transformed to [`Bool`](/type/Bool).
  
  ```raku
  my $n = Junction.new( "one", 1..6 );
  say $n.Bool;                         # OUTPUT: «False␤»
  
  ```
  
  All elements in this case are converted to `True`, so it's false to assert that only one of them is.
  
  ```raku
  my $n = Junction.new( "one", <0 1> );
  say $n.Bool;                         # OUTPUT: «True␤»
  
  ```
  
  Just one of them is truish in this case, `1`, so the coercion to [`Bool`](/type/Bool) returns `True`.
  
  # [In Capture](#___top "go to top of document")[§](#(Capture)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Capture#method_Bool)
  for **method Bool**.
  
  ```raku
  method Bool(Capture:D: --> Bool:D)
  ```
  
  Returns `True` if the `Capture` contains at least one named or one positional argument.
  
  ```raku
  say \(1,2,3, apples => 2).Bool; # OUTPUT: «True␤»
  say \().Bool;                   # OUTPUT: «False␤»
  ```
  
  # [In Allomorph](#___top "go to top of document")[§](#(Allomorph)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Allomorph#method_Bool)
  for **method Bool**.
  
  ```raku
  multi method Bool(::?CLASS:D:)
  ```
  
  Returns `False` if the invocant is numerically `0`, otherwise returns `True`. The [`Str`](/type/Str) value of the invocant is not considered.
  
  **Note**: For the `Allomorph` subclass [`RatStr`](/type/RatStr) also see [`Rational.Bool`](/type/Rational#method_Bool).
  
  # [In Str](#___top "go to top of document")[§](#(Str)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Str#method_Bool)
  for **method Bool**.
  
  ```raku
  method Bool(Str:D: --> Bool:D)
  ```
  
  Returns `False` if the string is empty, `True` otherwise.
  
  # [In role Setty](#___top "go to top of document")[§](#(role_Setty)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Setty#method_Bool)
  for **method Bool**.
  
  ```raku
  multi method Bool(Setty:D: --> Bool:D)
  ```
  
  Returns `True` if the invocant contains at least one element.
  
  ```raku
  my $s1 = Set.new(1, 2, 3);
  say $s1.Bool;                                     # OUTPUT: «True␤»
  
  my $s2 = $s1 ∩ Set.new(4, 5);                     # set intersection operator
  say $s2.Bool;                                     # OUTPUT: «False␤»
  ```
  
  # [In Promise](#___top "go to top of document")[§](#(Promise)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Promise#method_Bool)
  for **method Bool**.
  
  ```raku
  multi method Bool(Promise:D:)
  ```
  
  Returns `True` for a kept or broken promise, and `False` for one in state `Planned`.
  
  # [In Proc](#___top "go to top of document")[§](#(Proc)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Proc#method_Bool)
  for **method Bool**.
  
  ```raku
  multi method Bool(Proc:D:)
  ```
  
  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 Failure](#___top "go to top of document")[§](#(Failure)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Failure#method_Bool)
  for **method Bool**.
  
  ```raku
  multi method Bool(Failure:D: --> Bool:D)
  ```
  
  Returns `False`, and marks the failure as handled.
  
  ```raku
  sub f() { fail };
  my $v = f;
  say $v.handled; # OUTPUT: «False␤»
  say $v.Bool;    # OUTPUT: «False␤»
  say $v.handled; # OUTPUT: «True␤»
  ```
  
  # [In Regex](#___top "go to top of document")[§](#(Regex)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Regex#method_Bool)
  for **method Bool**.
  
  ```raku
  multi method Bool(Regex:D: --> Bool:D)
  ```
  
  Matches against the caller's [$\_](/syntax/$_) variable, and returns `True` for a match or `False` for no match.
  
  # [In Map](#___top "go to top of document")[§](#(Map)_method_Bool "direct link")
  
  See primary documentation
  [in context](/type/Map#method_Bool)
  for **method Bool**.
  
  ```raku
  method Bool(Map:D: --> Bool:D)
  ```
  
  Returns `True` if the invocant contains at least one key/value pair.
  
  ```raku
  my $m = Map.new('a' => 2, 'b' => 17);
  say $m.Bool;                                      # OUTPUT: «True␤»
  ```
  