2

collect:文字列を小文字に変換するのに役立つ方法はありますか? translateToLowercaseのように、またはの使用は許可されていませんasLowercase。私は答えが欲しいのではなく、私が始めるためにどこを見ることができるかについての考えだけです

4

1 に答える 1

4

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.

于 2013-06-06T23:16:30.487 に答える