Skip to content

_return

abinition edited this page Oct 22, 2014 · 5 revisions

#return

###Return from a method call.

Syntax

return[  expression ] ;

Arguments

  1. list expression(optional)

The expression is evaluated and the value is assigned to the method variable.

Description

A return can be executed to return from a method whether that method was called by the program itself or called via a message.

When called from within the program, the method variable get the result of the expression in the return variable. If the expression is not given, then the current value of the method being returned from becomes the return value. Methods not initialized or assigned a particular value default to "$ACKNOWLEDGE". The STATUS variable is also set with the same return value.

When return is executed for a message call, the the STATUS variable has the return value.

Examples

list M() { puts "MMM"; return 99; } ;
enable M ; on_message return 1 ; quiet; timestamp 0 ;

puts M() ;
puts query ( self, "M" ) ;

both result in...

MMM
99
MMM
99

Related Links

None

Clone this wiki locally