Using Nasal functions: Difference between revisions

Jump to navigation Jump to search
m
(→‎Anonymous function arguments: more contributions sent by PM)
Line 91: Line 91:
=== Returning from functions ===
=== Returning from functions ===


In Nasal, functions return implicitly the values of the last expression (i.e. "nil" in empty function bodies), you can also add an explicit "return" statement, for example to leave a function early. In addition, it is possible to return values, too.
In Nasal, functions return implicitly the values of the last expression (e.g. "nil" in empty function bodies), you can also add an explicit "return" statement, for example to leave a function early. In addition, it is possible to return values, too.


So, semantically, the previous snippet of code is equivalent to these:
So, semantically, these are all equivalent:


  var log_message = func {return;}
  var log_message = func {return;}
395

edits

Navigation menu