github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/continue.md (about) 1 # `continue` 2 3 > Terminate process of a block within a caller function 4 5 ## Description 6 7 `continue` will terminate execution of a block (eg `function`, `private`, 8 `foreach`, `if`, etc) right up until the caller function. In iteration loops 9 like `foreach` and `formap` this will result in behavior similar to the 10 `continue` statement in other programming languages. 11 12 ## Usage 13 14 ``` 15 continue block-name 16 ``` 17 18 ## Examples 19 20 ``` 21 %[1..10] -> foreach i { 22 if { $i == 5 } then { 23 out "continue" 24 continue foreach 25 out "skip this code" 26 } 27 out $i 28 } 29 ``` 30 31 Running the above code would output: 32 33 ``` 34 ยป foo 35 1 36 2 37 3 38 4 39 continue 40 6 41 7 42 8 43 9 44 10 45 ``` 46 47 ## Detail 48 49 `continue` cannot escape the bounds of its scope (typically the function it is 50 running inside). For example, in the following code we are calling `continue 51 bar` (which is a different function) inside of the function `foo`: 52 53 ``` 54 function foo { 55 %[1..10] -> foreach i { 56 out $i 57 if { $i == 5 } then { 58 out "exit running function" 59 continue bar 60 out "ended" 61 } 62 } 63 } 64 65 function bar { 66 foo 67 } 68 ``` 69 70 Regardless of whether we run `foo` or `bar`, both of those functions will 71 raise the following error: 72 73 ``` 74 Error in `continue` (7,17): no block found named `bar` within the scope of `foo` 75 ``` 76 77 ## See Also 78 79 * [`break`](../commands/break.md): 80 Terminate execution of a block within your processes scope 81 * [`exit`](../commands/exit.md): 82 Exit murex 83 * [`foreach`](../commands/foreach.md): 84 Iterate through an array 85 * [`formap`](../commands/formap.md): 86 Iterate through a map or other collection of data 87 * [`function`](../commands/function.md): 88 Define a function block 89 * [`if`](../commands/if.md): 90 Conditional statement to execute different blocks of code depending on the result of the condition 91 * [`out`](../commands/out.md): 92 Print a string to the STDOUT with a trailing new line character 93 * [`private`](../commands/private.md): 94 Define a private function block 95 * [`return`](../commands/return.md): 96 Exits current function scope 97 98 <hr/> 99 100 This document was generated from [builtins/core/structs/break_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/structs/break_doc.yaml).