Swift 3.0 学习 -- 大写和小写字符串(Uppercase and Lowercase Strings)

来源:互联网 发布:上海java培训机构排名 编辑:程序博客网 时间:2024/06/06 19:18

在swift2.0的时候,您可以通过字符串的uppercaseStringlowercaseString属性来访问大写/小写版本的字符串。如下:

let normal = "Could you help me, please?"let shouty = normal.uppercaseString// shouty 值为 "COULD YOU HELP ME, PLEASE?"let whispered = normal.lowercaseString// whispered 值为 "could you help me, please?"

但是在swift3.0中,字符串的uppercaseStringlowercaseString属性被函数 uppercased()和 lowercased()代替,如下:

let normal = "Could you help me, please?"let shouty = normal.uppercased()// shouty 值为 "COULD YOU HELP ME, PLEASE?"let whispered = normal.lowercased()// whispered 值为 "could you help me, please?"



0 0
原创粉丝点击