[squeak-dev] The Inbox: Kernel-ct.1342.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Sep 25 16:32:48 UTC 2020


A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ct.1342.mcz

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

Name: Kernel-ct.1342
Author: ct
Time: 25 September 2020, 6:32:44.665274 pm
UUID: 037ef8ee-228f-914b-8d1e-b05cac84772b
Ancestors: Kernel-eem.1341

Add ordinal suffix logic to Integer

Example:
	(1 to: 30) collect: [:ea | ea withOrdinalSuffix]

=============== Diff against Kernel-eem.1341 ===============

Item was added:
+ ----- Method: Integer>>ordinalSuffix (in category 'printing') -----
+ ordinalSuffix
+ 	"Answer a string containing the ordinal suffix of the receiver, e.g. 'th' for 4, or 'rd' for 23."
+ 
+ 	self \\ 100 // 10 = 1 ifFalse: [
+ 		self \\ 10
+ 			caseOf: {
+ 				[1] -> [^ 'st'].
+ 				[2] -> [^ 'nd'].
+ 				[3] -> [^ 'rd'] }
+ 			otherwise: []].
+ 	^ 'th'!

Item was added:
+ ----- Method: Integer>>printWithOrdinalSuffixOn: (in category 'printing') -----
+ printWithOrdinalSuffixOn: aStream
+ 
+ 	aStream
+ 		print: self;
+ 		nextPutAll: self ordinalSuffix.!

Item was added:
+ ----- Method: Integer>>withOrdinalSuffix (in category 'printing') -----
+ withOrdinalSuffix
+ 
+ 	^ String streamContents: [:stream |
+ 		self printWithOrdinalSuffixOn: stream]!



More information about the Squeak-dev mailing list