github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/return.md (about) 1 # `return` 2 3 > Exits current function scope 4 5 ## Description 6 7 `return` will terminate execution of a block at the scope level (eg `function`, 8 `private`, etc) 9 10 Conceptually it is the same as `break` except it doesn't require the scope name 11 as a parameter and you can specify the exit number rather than defaulting to 0. 12 13 ## Usage 14 15 ``` 16 return [ exit-number ] 17 ``` 18 19 ## Examples 20 21 **Setting an exit number:** 22 23 ``` 24 function example { 25 out foo 26 return 13 27 out bar 28 } 29 example 30 exitnum 31 ``` 32 33 Running the above code would output: 34 35 ``` 36 foo 37 13 38 ``` 39 40 **Returning withing an exit number:** 41 42 If we were to run the same code as above but with `return` written without any 43 parameters (ie instead of `return 13` it would be just `return`), then you 44 would see the following output: 45 46 ``` 47 foo 48 0 49 ``` 50 51 ## Detail 52 53 Any process that has been initialised within a `return`ed scope will have their 54 exit number updated to the value specified in `return` (or `0` if no parameter 55 was passed). 56 57 ## See Also 58 59 * [`break`](../commands/break.md): 60 Terminate execution of a block within your processes scope 61 * [`continue`](../commands/continue.md): 62 Terminate process of a block within a caller function 63 * [`exit`](../commands/exit.md): 64 Exit murex 65 * [`exitnum`](../commands/exitnum.md): 66 Output the exit number of the previous process 67 * [`function`](../commands/function.md): 68 Define a function block 69 * [`out`](../commands/out.md): 70 Print a string to the STDOUT with a trailing new line character 71 * [`private`](../commands/private.md): 72 Define a private function block 73 74 <hr/> 75 76 This document was generated from [builtins/core/structs/break_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/structs/break_doc.yaml).