|
Re: collection enumeration: msg#00212lang.smalltalk.squeak.beginners
Bert Freudenberg wrote:
I would vote for #withIndexDo: too which has in 'intention revealing name' :-) And, please forget about (b), this is way too slow and wrong. Slow because the complexity jump from O(n) to O(n²). Remember that #indexOf: has to search for the element in all the collection. Wrong because: collection := #($a $b $a). collection do: [:each | Transcript show: (collection indexOf: each); space] Will print '1 2 1' instead of '1 2 3'. Index answered by #indexOf: if the first index on which the object is found. Bye
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: collection enumeration, cdrick |
|---|---|
| Next by Date: | Re: collection enumeration, stéphane ducasse |
| Previous by Thread: | Re: collection enumeration, cdrick |
| Next by Thread: | Re: collection enumeration, stéphane ducasse |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |