13.07.2015 Views

Smalltalk Best Practice Patterns Volume 1: Coding - Free

Smalltalk Best Practice Patterns Volume 1: Coding - Free

Smalltalk Best Practice Patterns Volume 1: Coding - Free

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

vitalInformation| result |result := Dictionary new.resultat: ‘weight’put: 190.resultat: ‘hair’put: ‘blond’.^resultcheckOut: aPerson| info |info := aPerson vitalInformation.(info at: ‘weight’) < 280 & ((info at: ‘hair’) = ‘black’) ifTrue: ...I’ve also done the same thing with Arrays of fixed size where different indexes mean differentthings:vitalInformation^Arraywith: 190with: ‘blond’checkOut: aPerson| info |info := aPerson vitalInformation.(info at: 1) < 280 & ((info at: 2) = ‘black’) ifTrue: ...This is your program’s way of telling you “there’s a new object here”. The new object will haveone instance variable for each element in the collection.If you implement an Equality Method for Dictionary keys you must also implement a HashingMethod.<strong>Coding</strong> <strong>Patterns</strong> page 95 of 147 9/30/2006

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!