syntax to do array as value:value:...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

syntax to do array as value:value:...

LordGeoffrey
Is there a method that does what magicDo does?

#(#(1 2 true)
    #(2 1 false)) magicDo: [:a :b :r |
         "do something useful"
    ]      
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: syntax to do array as value:value:...

Randal L. Schwartz
>>>>> "LordGeoffrey" == LordGeoffrey  <[hidden email]> 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> [hidden email]
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
<[hidden email]> <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
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: syntax to do array as value:value:...

LordGeoffrey
Prefect. Thanks.

Randal L. Schwartz wrote:
"LordGeoffrey" == LordGeoffrey  [hidden email] 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> [hidden email]
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:

  


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners