[squeak-dev] The Trunk: Collections-eem.755.mcz

commits at source.squeak.org commits at source.squeak.org
Thu May 25 22:30:57 UTC 2017


Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.755.mcz

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

Name: Collections-eem.755
Author: eem
Time: 25 May 2017, 3:30:29.925042 pm
UUID: b20639f6-1b01-45b5-8311-6abe8fad12c7
Ancestors: Collections-nice.754

Fix withoutTrailingDigits for e.g. 'Lucida Grande 15' withoutTrailingDigits.  Harvested from Terf.

=============== Diff against Collections-nice.754 ===============

Item was changed:
  ----- Method: String>>withoutTrailingDigits (in category 'converting') -----
  withoutTrailingDigits
  	"Answer the portion of the receiver that precedes any trailing series of digits and blanks.  If the receiver consists entirely of digits and blanks, return an empty string"
+ 	| i |
+ 	i := self size.
+ 	[i > 0] whileTrue: [ 
+ 		((self at: i) isDigit or: [ (self at: i) = $ ]) ifFalse: [
+ 			^ self copyFrom: 1 to: i
+ 		].
+ 		i := i - 1.
+ 	].
+ 	^ ''
+ 	
- 	| firstDigit |
- 	firstDigit := (self findFirst: [:m | m isDigit or: [m = $ ]]).
- 	^ firstDigit > 0
- 		ifTrue:
- 			[self copyFrom: 1 to: firstDigit-1]
- 		ifFalse:
- 			[self]
  
  "
  'Whoopie234' withoutTrailingDigits
+ 'Lucida Grande 15' withoutTrailingDigits
  ' 4321 BlastOff!!' withoutLeadingDigits
  'wimpy' withoutLeadingDigits
  '  89Ten ' withoutLeadingDigits
  '78 92' withoutLeadingDigits
  "
  !



More information about the Squeak-dev mailing list