return
Exits a function. You need to make sure you have pushed any results onto the stack before calling the instruction.

Syntax

return

Examples

(func $inRange
  (param $number i32)
  (param $min i32)
  (param $max i32)
  (result i32)
  ;; Compare $number and $min
  local.get $number
  local.get $min
  i32.lt_s

  ;; If number is smaller
  if
    ;; Return out of range
    local.const 0
    return
  if

  ;; Compare $number and $max
  local.get $number
  local.get $max
  i32.gt_s

  ;; If number is greater
  if
    ;; Return out of range
    local.const 0
    return
  if

  ;; Return is in range
  local.const 1
)