Finally [v1.1.14+]

Ensures that one or more statements (commands or expressions) are always executed after the execution of a try statement.

FinallyStatement

Finally
{
Statements
}

Remarks

Every use of finally must belong to (be associated with) a try (or catch) statement above it. A finally always belongs to the nearest unclaimed try statement above it unless a block is used to change that behavior.

Try statements behave differently depending on whether catch or finally is present. For more information, see Try.

Goto, break, continue and return cannot be used to exit a finally block, as that would require suppressing any control flow instructions within the try block. For example, if try uses return 42, the value 42 is returned after the finally block executes. Attempts to jump out of a finally block using one of these commands are detected as errors at load time where possible, or at run time otherwise.

Prior to [v1.1.19.02], a bug existed which prevented control flow statements within try from working when finally was present. Return was erroneously permitted within finally, but was ignored if an exception had been thrown.