Skip to content
On this page

Statements: Return

ReturnStatement :
  ExplicitReturnStatement | ImplicitReturnStatement
ExplicitReturnStatement :
  return Expression? ;
ImplicitReturnStatement :

Explicit Return

The return statement is used to return a value from a function.

function example(): int {
    return 1;

The return statement can be used without a value to exit a function early.

function example(): void {
    if $condition {

    // ...

Implicit Return

A function can return implicitly by omitting the return keyword and the semicolon.

function example(): int {


Multiple return statements in the same code path will result in a compile-time error.

Licensed under either of the MIT License or the Apache License (Version 2.0), at your option.