Product Site

5.1.4.21. sendWith

Returns the result of invoking a method on the target object using the specified message name and arguments. The sendWith method allows methods to be invoked using dynamically constructed method names and arguments.

The messagename can be a string or an array. If messagename is an array object, its first item is the name of the message and its second item is a class object to use as the starting point for the method search.

The arguments argument must be a single-dimensional Array instance. The values contained in arguments are passed to the receiver as arguments for messagename in the order you specify them.
Example 5.36. Object class — sendWith method
world = .WorldObject~new
-- these calls are equivalent and produce "Hello World, I'm Fred!"
say world~hello("World", "Fred")
say world~sendWith("HELLO", .Array~of("World", "Fred"))

::class WorldObject
::method hello
  use strict arg place, name
  return "Hello" place", I'm"  name"!"