[Cuis-dev] The Cuis-Smalltalk Book Exercise 2.3: Count of methods

Ezequiel Birman ebirman77 at gmail.com
Fri Dec 1 13:56:16 PST 2023


The exercise is:

> How many methods are there in the arithmetic method category of the String
> class?
>

There are no messages categorized as arithmetic in String but in
CharacterSequence, which String subclassifies. Maybe it was different
before; Squeak Strings implement arithmetic messages, exactly those
mentioned in the solution to the exercise:

> the count of methods in the last right panel is 6: *, +, -, /, // and \\.
>
But `String allMethodsInCategory: 'arithmetic'` in both Cuis and Squeak
evaluates as:

>  #(#* #+ #- #/ #// #\\ #raisedTo:)
>
Seven methods and yes! you can raise the empty string to the power of n for
n ∈ Number. WAT! The result is another empty string :) Are we able to do
this because of historical reasons? Strings in Squeak can be added E.g `'3'
+ '4'` is the string '7'.

Btw, I'm sharing my annotations
<https://hyp.is/k4BuJpCLEe6_Z59nfniWQQ/cuis-smalltalk.github.io/TheCuisBook/A-brief-introduction-to-the-system-Browser.html>
via hypothes.is publicly but you'll need to install the Chrome plugin or
the unofficial Firefox extension
<https://github.com/diegodlh/unofficial-hypothesis-extension> to see them.
I've requested to use their proxy so you don't have to, but it might take
some time. Once you install any of the plugins you'll be able to read and
write comments. The UI looks like this:
[image: imagen.png]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20231201/0e09be30/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imagen.png
Type: image/png
Size: 138874 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20231201/0e09be30/attachment-0001.png>


More information about the Cuis-dev mailing list