(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)
local.get $first
local.get $second
i32.add
)
(func $doubleBoth (param $first i32) (param $second i32) (result i32 i32)
local.get $first
i32.const 2
i32.mul
local.get $second
i32.const 2
i32.mul
)
(func $test
i32.const 42
i32.const 101
call $doubleBoth
)