exit flow control statement will terminate the execution of the current method and directly exit back to the code that called it.
If the current method has a result type, then
exit can optionally provide a return value that will be passed back to the caller. If such a value is provided, it will replace whatever value may already be stored in the
result variable. If
exit is invoked without a return value, any value already stored in
result will be returned.
exit will break out of any loops and skip executing any further code that is written as part of the current method.
exit will honor any code provided in
method Test: String; begin writeLn('Hello'); result := 'Hello'; exit; writeLn('This line won''t run'); end; method Test2: String; begin writeLn('Hello'); exit 'Hello'; writeLn('This line won''t run'); end; method Test3; begin writeLn('Hello'); exit; writeLn('This line won''t run'); end;