Smalltalk Best Practice Patterns Volume 1: Coding - Free
Smalltalk Best Practice Patterns Volume 1: Coding - Free
Smalltalk Best Practice Patterns Volume 1: Coding - Free
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
DoHow do you execute code for each element in a collection?This is the fundamental piece out of which the rest of the enumeration messages a built. If this werea procedural language, you would have a small set of idioms for iterating through a collection, onefor a linked list, one for an array, one for a hash table.For purposes of enumeration, there is no difference between the collection classes in <strong>Smalltalk</strong>. Asa programmer you never explicitly deal with walking pointers along a list or iterating a loopcounter. You just send the message “do:” and magic happens.In spite of the simplicity of do:, I still occasionally see code where someone slips into previoushabits and writes:index := 1.[index