Run a procedure.
If the procedure name is not dynamic, you do need the run(..)
function but instead you may call the procedure as a function call.
This function does not generate a change.
run(procedure, ...args)
Argument | Type | Description |
---|---|---|
procedure | str (required) | Name of the procedure to run. |
…args | any | The arguments for the procedure. If more arguments are given than the procedure expects, the redundant arguments will be ignored. If too few arguments are given, then the remaining arguments will be set to nil. |
Returns the procedure response.
Example code using run:
// create a greet procedure
new_procedure('greet', |name| is_str(name)
? "Hello " + name
: "Hello unnamed user!"
);
// run `greet` with a given name
greet_iris = run('greet', "Iris"); // equal to: greet("Iris");
// run `greet` with nil
greet_nil = run('greet', nil); // equal to: greet();
// return the greet response values
[greet_iris, greet_nil];
Return value in JSON format
[
"Hello Iris",
"Hello unnamed user!"
]