Types

Return

Return instance types, when thrown, will exit the call frame where they were created returning given value.

Example

{
    F find_the_one(haystack:Arr, needle) {
        ret_from_find_the_one = Return()
        echo(ret_from_find_the_one)
        haystack.each(F(elt) {
                elt == needle throws ret_from_find_the_one("Found it!")
        })
        "Not found"
    }
    echo([10,20].find_the_one(20))
    echo([10,20].find_the_one(30))
}
# Output:
#   <Return closure=<Closure find_the_one at 1.ngs:2> depth=7 val=null>
#   Found it!
#   <Return closure=<Closure find_the_one at 1.ngs:2> depth=7 val=null>
#   Not found

Constructors

Return()
Get closure-specific Return type. Throwing it, will return from the closure

Methods

call(r:Return, v:Any=null)
Implements calling of Return type instances like the finish(i) call in the example below