reverse.
In the preceding example, sending the reverse
message to the !iH object causes it to run the
reverse method. Most objects are capable
of more than one action, and so have a number of available methods.completed,
init, notify,
result, send, and
start methods.
When you create your own classes, you can write new methods for them
in Rexx code. Much of the object programming in Rexx is writing the code for
the methods you create.
"!iH"~reverse -- Reverses the characters "!iH" to form "Hi!"
pen~reverse -- Reverses the direction of a plotter pen
ball~reverse -- Reverses the direction of a moving ball
reverse
method, reverse runs
even if the programming implementation is different for each object.
Each object knows only its own version of reverse.
And even though the objects are different, each reverses itself as
dictated by its own code.!iH object's
reverse code is different from
the plotter pen's, the method name can be the same because Rexx keeps
track of the methods each object owns.
You do not need to have several message names like
reverse_string, reverse_pen,
reverse_ball.
This keeps method-naming schemes simple and makes
complex programs easy to follow and modify.