The Trunk: Collections-mt.605.mcz

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

The Trunk: Collections-mt.605.mcz

commits-2
Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.605.mcz

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

Name: Collections-mt.605
Author: mt
Time: 30 March 2015, 8:46:49.164 am
UUID: b661cec7-af10-7a42-9c4c-a09449425548
Ancestors: Collections-ul.604

Support #withBlanksTrimmed in texts.

=============== Diff against Collections-ul.604 ===============

Item was added:
+ ----- Method: String class>>noSeparators (in category 'accessing') -----
+ noSeparators
+ ^ CSNonSeparators!

Item was added:
+ ----- Method: Text>>withBlanksTrimmed (in category 'converting') -----
+ withBlanksTrimmed
+ "Return a copy of the receiver from which leading and trailing blanks have been trimmed."
+
+ | first last |
+ first := string indexOfAnyOf: String noSeparators startingAt: 1 ifAbsent: [0].
+ first = 0 ifTrue: [ ^'' ].  "no non-separator character"
+ last := string lastIndexOfAnyOf: String noSeparators startingAt: self size ifAbsent: [self size].
+ (first = 1 and: [ last = self size ]) ifTrue: [ ^self copy ].
+ ^self
+ copyFrom: first
+ to: last
+ !


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.605.mcz

Levente Uzonyi-2
On Mon, 30 Mar 2015, [hidden email] wrote:

> Marcel Taeumel uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-mt.605.mcz
>
> ==================== Summary ====================
>
> Name: Collections-mt.605
> Author: mt
> Time: 30 March 2015, 8:46:49.164 am
> UUID: b661cec7-af10-7a42-9c4c-a09449425548
> Ancestors: Collections-ul.604
>
> Support #withBlanksTrimmed in texts.
>
> =============== Diff against Collections-ul.604 ===============
>
> Item was added:
> + ----- Method: String class>>noSeparators (in category 'accessing') -----
> + noSeparators
> + ^ CSNonSeparators!

I like the idea of a shared CharacterSet with the non-separator
characters, but IMHO it should be on the class side of CharacterSet and I
prefer the name #nonSeparators.
Any objections?

Levente

>
> Item was added:
> + ----- Method: Text>>withBlanksTrimmed (in category 'converting') -----
> + withBlanksTrimmed
> + "Return a copy of the receiver from which leading and trailing blanks have been trimmed."
> +
> + | first last |
> + first := string indexOfAnyOf: String noSeparators startingAt: 1 ifAbsent: [0].
> + first = 0 ifTrue: [ ^'' ].  "no non-separator character"
> + last := string lastIndexOfAnyOf: String noSeparators startingAt: self size ifAbsent: [self size].
> + (first = 1 and: [ last = self size ]) ifTrue: [ ^self copy ].
> + ^self
> + copyFrom: first
> + to: last
> + !
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.605.mcz

marcel.taeumel (old)
Sounds good! :)

Best,
Marcel