[Newbies] syntax to do array as value:value:...

Randal L. Schwartz merlyn at stonehenge.com
Fri Dec 25 13:50:15 UTC 2009

>>>>> "LordGeoffrey" == LordGeoffrey  <lordgeoffrey at optusnet.com.au> writes:

LordGeoffrey> Is there a method that does what magicDo does?
LordGeoffrey> #(#(1 2 true)
LordGeoffrey>    #(2 1 false)) magicDo: [:a :b :r |
LordGeoffrey>         "do something useful"
LordGeoffrey>    ]       _______________________________________________
LordGeoffrey> Beginners mailing list
LordGeoffrey> Beginners at lists.squeakfoundation.org
LordGeoffrey> http://lists.squeakfoundation.org/mailman/listinfo/beginners

what do you want a, b, and r to be?

Maybe the values 1, 2, true the first time, and 2, 1, false the second?

If so:

#((1 2 true) (2 1 false)) do: [:row |
   [:a :b :r | "do something useful" ] valueWithArguments: row.

Beware... if your row doesn't have exactly three values, you'll
get an exception.  If you don't want that, consider #valueWithPossibleArgs:

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

More information about the Beginners mailing list