(result...)
Declares the returning result values. This is used to state what values and data types will be placed onto the stack after the code block exits. This is used with (func...), (if...), (loop...) and (block...).

Syntax

(result type1 typeN)

Parameters

type1
The data type the result uses. There must be at least one data type.
typeN Optional
You can list as many different types as you want. A function can return more than one value with different data types.

Examples

(func $add (param $first i32) (param $second i32) (result i32)
  ;; Add first and second parameters together and return result
  local.get $first
  local.get $second
  i32.add
)
(func $doubleBoth (param $first i32) (param $second i32) (result i32 i32)
  ;; Double the $first parameter
  local.get $first
  i32.const 2
  i32.mul

  ;; Double the $second parameter
  local.get $second
  i32.const 2
  i32.mul
)

(func $test
  ;; Push parameters onto the stack
  i32.const 42
  i32.const 101

  ;; Call the $doubleBoth function
  call $doubleBoth

  ;; The stack contains the returned results of
  ;; i32 value of 202
  ;; i32 value of 84
)