Squeak programming question
Dan Ingalls
DanI at wdi.disney.com
Mon Mar 22 20:31:24 UTC 1999
>Quick programming question from a Squeak/Smalltalk newbie:
>
>Is there any elegant method for handling occasions when you
>wish a method to return multiple objects?
I pretty much subscribe to the solutions proffered so far (returning an array and using a block). However I offer the following for your entertainment (fasten seat belts)...
Given a method like:
twoValues
^ {1. 2}
then the following code fragment
{a. b} := self twoValues.
will result in a=1, b=2.
In fact you can even do
{a. b} := {b. a}
to exchange two values without a third temporary variable.
- Dan
More information about the Squeak-dev
mailing list
|