Click or drag to resize

ASend Function

X#
Invoke a method for every element in an array of objects.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION ASend(
	aTarget AS ARRAY,
	symMethod AS STRING,
	MethodArgList PARAMS USUAL[]
) AS ARRAY
Request Example View Source

Parameters

aTarget
Type: Array
The array to process.
symMethod
Type: String
The method name, specified without parentheses.
MethodArgList
Type: Usual
A comma-separated list of arguments to pass to symMethod.

Return Value

Type: Array
A reference to aTarget.
Remarks
Examples
This example sends a simple message to an array of objects for evaluation.
Each elemental object evaluates the message in turn:
X#
 1CLASS Greet
 2METHOD Salut(cRest) CLASS Greet
 3    ? Hello", cRest
 4    RETURN
 5END CLASS
 6FUNCTION Start()
 7    LOCAL oAlpha, oBeta, oGamma, oDelta, oEpsilon ;
 8        AS OBJECT
 9    LOCAL aBunch AS ARRAY
10    oAlpha   := Greet{}
11    oBeta    := Greet{}
12    oGamma    := Greet{}
13    oDelta   := Greet{}
14    oEpsilon := Greet{}
15    aBunch := {oAlpha, oBeta, oGamma, oDelta, oEpsilon}
16    ASend(aBunch, #Salut, "world")
17    // Equivalent output
18    AEval(aBunch, {|aTemp| aTemp:Salut("world")})
See Also