我有一个字符串数组,但所有的叮当都是用大写字母写的.有没有办法让我将数组中的所有字符串设置为小写(并且使用大小写) array = ["BOY","GIRL","MAN"] // func to convert it to array = ["Boy","Girl",
array = ["BOY","GIRL","MAN"] // func to convert it to array = ["Boy","Girl","Man"]
有没有办法做到这一点,而不用小写字母重写数组的内容.我用大写字母组成了很长的字符串数组.
你可以像这样使用map函数:let array = ["BOY","GIRL","MAN"] let capitalizedArray = array.map { $0.capitalizedString}