About Optional Return Statements

In standard JavaScript, the return statement is required anytime you want to return a value from a function call. In DScript, it is optional if you want to return the value of the last expression in the definition's statement block. That is, the following code:

{
  statement1
  statement2
  return expression;
}

is the same as

{
  statement1
  statement2
  expression;
}

This extension in DScript's lexical structure is required to allow DScript to support simple definitions. For example, you can replace the compound definition:

Square(x):= {
  return x*x;
}

with the simple definition:

Square(x):=x*x

In the simple definition, return is implied.

See About the Return Statement.