github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/and.md (about) 1 # `and` 2 3 > Returns `true` or `false` depending on whether multiple conditions are met 4 5 ## Description 6 7 Returns a boolean results (`true` or `false`) depending on whether all of the 8 code-blocks included as parameters are successful or not. 9 10 ## Usage 11 12 ``` 13 and { code-block } { code-block } -> <stdout> 14 15 !and { code-block } { code-block } -> <stdout> 16 ``` 17 18 `and` supports as many or as few code-blocks as you wish. 19 20 ## Examples 21 22 ``` 23 if { and { = 1+1==2 } { = 2+2==4 } { = 3+3==6 } } then { 24 out The laws of mathematics still exist in this universe. 25 } 26 ``` 27 28 ## Detail 29 30 `and` does not set the exit number on failure so it is safe to use inside a `try` 31 or `trypipe` block. 32 33 If `and` is prefixed by a bang then it returns `true` only when all code-blocks 34 are unsuccessful. 35 36 ### Code-Block Testing 37 38 * `and` tests all code-blocks up until one of the code-blocks is unsuccessful, 39 then `and` exits and returns `false`. 40 41 * `!and` tests all code-blocks up until one of the code-blocks is successful, 42 then `!and` exits and returns `false` (ie `!and` is `not`ing every code-block). 43 44 ## Synonyms 45 46 * `and` 47 * `!and` 48 49 50 ## See Also 51 52 * [`!` (not)](../parser/not-func.md): 53 Reads the STDIN and exit number from previous process and not's it's condition 54 * [`catch`](../commands/catch.md): 55 Handles the exception code raised by `try` or `trypipe` 56 * [`false`](../commands/false.md): 57 Returns a `false` value 58 * [`if`](../commands/if.md): 59 Conditional statement to execute different blocks of code depending on the result of the condition 60 * [`or`](../commands/or.md): 61 Returns `true` or `false` depending on whether one code-block out of multiple ones supplied is successful or unsuccessful. 62 * [`true`](../commands/true.md): 63 Returns a `true` value 64 * [`try`](../commands/try.md): 65 Handles non-zero exits inside a block of code 66 * [`trypipe`](../commands/trypipe.md): 67 Checks for non-zero exits of each function in a pipeline 68 69 <hr/> 70 71 This document was generated from [builtins/core/structs/andor_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/structs/andor_doc.yaml).