txt: ## notandthen.md
  notandthen
  
  Combined from primary sources listed below.
  
  # [In Operators](#___top "go to top of document")[§](#(Operators)_infix_notandthen "direct link")
  
  See primary documentation
  [in context](/language/operators#infix_notandthen)
  for **infix notandthen**.
  
  The `notandthen` operator returns [`Empty`](/type/Slip#constant_Empty) upon encountering the first [defined](/routine/defined) argument, otherwise the last argument. Last argument is returned as-is, without being checked for definedness at all. Short-circuits. The result of the left side is bound to `$_` for the right side, or passed as arguments if the right side is a [`Callable`](/type/Callable), whose [count](/routine/count) must be `0` or `1`.
  
  At first glance, [notandthen](/routine/notandthen) might appear to be the same thing as the [orelse](/routine/orelse) operator. The difference is subtle: [notandthen](/routine/notandthen) returns [`Empty`](/type/Slip#constant_Empty) when it encounters a [defined](/routine/defined) item (that isn't the last item), whereas [orelse](/routine/orelse) returns that item. In other words, [notandthen](/routine/notandthen) is a means to act when items aren't defined, whereas [orelse](/routine/orelse) is a means to obtain the first defined item:
  
  ```raku
  sub all-sensors-down     { [notandthen] |@_, True             }
  sub first-working-sensor { [orelse]     |@_, 'default sensor' }
  
  all-sensors-down Nil, Nil, Nil
    and say 'OMG! All sensors are down!'; # OUTPUT:«OMG! All sensors are down!␤»
  say first-working-sensor Nil, Nil, Nil; # OUTPUT:«default sensor␤»
  
  all-sensors-down Nil, 42, Nil
    and say 'OMG! All sensors are down!'; # No output
  say first-working-sensor Nil, 42, Nil;  # OUTPUT:«42␤»
  
  ```
  
  The `notandthen` operator is a close relative of the [`without` statement modifier](/language/control#with_orwith_without), and some compilers compile `without` to `notandthen`, meaning these two lines have equivalent behavior:
  
  ```raku
  sub good-things { fail }
  
  'boo'.say without good-things;
  good-things() notandthen 'boo'.say;
  
  ```
  