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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

aCollection isEmptyifTrue: [empty := true]ifFalse: [empty := false]Using Conditional Expression we first factor out the assignment:empty := aCollection isEmptyifTrue: [true]ifFalse: [false]We can go a step further and eliminate the conditional entirely. The following code is equivalent tothe preceding:empty := aCollection isEmptyYou may be able to express one or both branches of the conditional more explicitly by using aComposed Method.<strong>Coding</strong> <strong>Patterns</strong> page 133 of 147 9/30/2006

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

Saved successfully!

Ooh no, something went wrong!