[Newbies] [Q] Best way of doing ...
Randal L. Schwartz
merlyn at stonehenge.com
Tue May 5 13:37:06 UTC 2009
>>>>> "Edgar" == Edgar J De Cleene <edgardec2001 at yahoo.com.ar> writes:
Edgar> I need a way for two collections of different size could be tested for all
Edgar> elements in both.
Edgar> A := #(a1 a2 a3).
Edgar> B := #(b1 b2 b3 b4 b5).
Edgar> Some similar to
Edgar> with: otherCollection do: twoArgBlock
Edgar> "Evaluate twoArgBlock with corresponding elements from this collection
Edgar> and otherCollection."
Edgar> otherCollection size = self size
Edgar> But for different size
When they are different sizes, what do you want done with
mismatched elements? Call the block anyway, passing nil for the
shorter list? Or not call the block at all?
And depending on your choice, you should name the method clearly:
the latter, you could call as:
a with: b ifAbsent: nil do: [ ... ]
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