Core Function Return

From Sputnik Wiki
Revision as of 03:51, 23 September 2013 by UberFoX (Talk | contribs)
Jump to: navigation, search
Return <expressions>
yield Return <expressions>

Contents

Description

Immediately ends execution of the current function, and returns its argument as the value of the function call. return will also end the execution of an Eval() statement or script file

expressions

The expressions to return from the function can be a single variable or even arrays.

This can also just be nothing like

return;

Return Value

You decide.

Remarks

If you add yield before the Return it will save the current iteration of a loop and start from that point again the next time you use that loop (as long as the arrays internal pointer hasn't changed position).

Example

A simple numeric return

$value = Add(10, 20);
 
println("Value is $value"); // Prints 30
 
Function Add($a, $b)
{
	return $a + $b;
}

Return an array

List( $Name, $ID ) = Test("UberFoX", 777);
 
println("Name: $Name | ID: $ID");
// Prints Name: UberFoX | ID: 777
 
Function Test( $Name, $ID )
{
	return array($Name, $ID);
}


Return nothing

$value = Test();
 
println("Value is $value"); // Prints 30
 
Function Test($a, $b)
{
	my $Test = $a;
	my $foo = "Bar";
	return;
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox