1 Matching Annotations
- Dec 2023
-
cuis-smalltalk.github.io cuis-smalltalk.github.io
-
How many methods are there in the arithmetic method category of the CharacterSequence class?
There are no messages categorized as arithmetic in String but in CharacterSequence, which String subclassifies. Squeak Strings on the other hand, implement arithmetic messages, exactly those mentioned in the solution to the exercise; Note however that
String allMethodsInCategory: #arithmetic
in both Cuis and Squeak include a seventh method#raisedTo:
because#allMethodsInCategory
also looks up for inherited methods from superclasses. Yes! you can raise the empty string to the power of n for n ∈ Number and the result is another empty string! WAT :) The fact that we can evaluate'' raisedTo: n
without error seems like an unforeseen consequence of#adaptToCollection:andSend:
relying on#collect
and how the latter works on empty collections.
-