Search code examples
smalltalk

Smalltalk - convert string to lowercase


Is there a way to use collect: to help convert a string to lowercase? As in, I'm not allowed to use translateToLowercase or asLowercase. I don't want the answer, just an idea of where I could look to get me started


Solution

  • You can use collect as a sort of mapping operation. Here is an example:

    (1 to: 10) collect: [ :x | x squared ] "=> [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]"
    

    For your purposes you'd want to use something other than squared. This will let you perform the operation one character at a time.

    Hope this helps, you said you didn't want the answer.