Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法collect:帮助将字符串转换为小写?如,我不允许使用translateToLowercaseor asLowercase。我不想要答案,只是想知道我可以从哪里开始
collect:
translateToLowercase
asLowercase
您可以collect用作一种映射操作。这是一个例子:
collect
(1 to: 10) collect: [ :x | x squared ] "=> [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]"
出于您的目的,您希望使用squared. 这将让您一次执行一个字符的操作。
squared
希望这会有所帮助,你说你不想要答案。