The Trunk: Collections-ar.205.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-ar.205.mcz

commits-2
Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ar.205.mcz

==================== Summary ====================

Name: Collections-ar.205
Author: ar
Time: 21 November 2009, 1:07:12 am
UUID: 0550788a-c49c-ef4c-a9bc-ded59113fd53
Ancestors: Collections-ar.204

Collection>>ifEmpty: and Collection>>ifNotEmpty: should behave like #ifNil: and return self unless the condition is met. Makes collection manipulation easier, for example
        port := ((hostname copyAfter: $:) ifEmpty:['80']) asInteger
instead of
        portString:= hostname copyAfter: $:.
        portString ifEmpty:[portString := '80'].
        port := portString asInteger.
etc.


=============== Diff against Collections-ar.204 ===============

Item was changed:
  ----- Method: Collection>>ifNotEmptyDo: (in category 'testing') -----
  ifNotEmptyDo: aBlock
  "Evaluate the given block with the receiver as its argument."
 
+ self isEmpty ifFalse: [^ aBlock value: self].
- ^self isEmpty ifFalse: [aBlock value: self].
  !

Item was changed:
  ----- Method: Collection>>ifEmpty: (in category 'testing') -----
  ifEmpty: aBlock
  "Evaluate the block if I'm empty"
 
+ self isEmpty ifTrue: [ ^aBlock value ]!
- ^self isEmpty ifTrue: [ aBlock value ]!

Item was changed:
  ----- Method: Collection>>ifNotEmpty: (in category 'testing') -----
  ifNotEmpty: aBlock
  "Evaluate the given block unless the receiver is empty.
 
        If the block has an argument, eval with the receiver as its argument,
        but it might be better to use ifNotEmptyDo: to make the code easier to
        understand"
 
+ self isEmpty ifFalse: [^ aBlock valueWithPossibleArgument: self].
- ^self isEmpty ifFalse: [aBlock valueWithPossibleArgument: self].
  !