[squeak-dev] The Inbox: Collections-ct.858.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Tue Oct 15 06:42:27 UTC 2019


Hmm... given that I always remember #withFirstCharacterDownshifted but not #capitalized ... I think there might be something missing here. :-)

Yes, if we would add #withFirstCharacterUpshifted, it should just call #capitalized directly.

Well, looking at Wikipedia (https://en.wikipedia.org/wiki/Capitalization [https://en.wikipedia.org/wiki/Capitalization]), I wonder why 

'hello world' capitalized

does not yield

'Hello World'

but only

'Hello world'

... because it says "...writing a word with its first letter [https://en.wikipedia.org/wiki/Letter_(alphabet)] as a capital letter..." so 'hello world' has two words in it.

So, #withFirstCharacterDownshifted refers to the string full of characters. #capitalized actually should refer to words.

Anyway, I think that #withFirstCharacterUpshifted cannot hurt. :-)

+0.5

Best,
Marcel
Am 14.10.2019 22:37:25 schrieb Chris Muller <asqueaker at gmail.com>:
-1.

Using the Method Finder, enter

     'hello'.  'Hello'

to see we already have #capitalized to do that.

Before introducing new API, always research existing nomenclature's.  Uncapitalization is not a common use-case, but if you want to introduce it into Squeak, I'd suggest #uncapitalized instead of two new methods named "Upshifted" and "Downshifted".  Those words describe the "procedure for obtaining a capital letter from a keyboard" (except "Downshifted," which only describes a car with a manual transmission, ready to burn rubber  :)  ).  By contrast, the #capitalized API describes the nature of the object itself.

Best,
  Chris


On Sun, Oct 13, 2019 at 3:34 PM <commits at source.squeak.org [mailto:commits at source.squeak.org]> wrote:

A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ct.858.mcz [http://source.squeak.org/inbox/Collections-ct.858.mcz]

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

Name: Collections-ct.858
Author: ct
Time: 13 October 2019, 10:33:55.310932 pm
UUID: 80a9daa4-d11d-554c-8530-f4d5a1a70c8f
Ancestors: Collections-pre.857

Adds #withFirstCharacterUpshifted analogously to #withFirstCharacterDownshifted

=============== Diff against Collections-pre.857 ===============

Item was changed:
  ----- Method: String>>withFirstCharacterDownshifted (in category 'converting') -----
  withFirstCharacterDownshifted
-       "Return a copy with the first letter downShifted"

        | answer |
-       
        self ifEmpty: [^ self copy].
        answer := self copy.
        answer at: 1 put: (answer at: 1) asLowercase.
+       ^ answer!
-       ^ answer. !

Item was added:
+ ----- Method: String>>withFirstCharacterUpshifted (in category 'converting') -----
+ withFirstCharacterUpshifted
+
+       | answer |
+       self ifEmpty: [^ self copy].
+       answer := self copy.
+       answer at: 1 put: (answer at: 1) asUppercase.
+       ^ answer!

Item was changed:
  ----- Method: Symbol>>withFirstCharacterDownshifted (in category 'converting') -----
  withFirstCharacterDownshifted
+       "Answer an object like the receiver but with first character downshifted if necessary"
-       "Answer an object like the receiver but with first character downshifted if necesary"

+       ^self asString withFirstCharacterDownshifted asSymbol!
-       ^self asString withFirstCharacterDownshifted asSymbol.!

Item was added:
+ ----- Method: Symbol>>withFirstCharacterUpshifted (in category 'converting') -----
+ withFirstCharacterUpshifted
+       "Answer an object like the receiver but with first character upshifted if necessary"
+
+       ^self asString withFirstCharacterUpshifted asSymbol!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20191015/f117b7ce/attachment.html>


More information about the Squeak-dev mailing list