9月9学习内容


let grade =100 let rank: String switch grade { case 0 ... 59: rank "F" case 60 ... 69: rank "D" case 70 ...79: rank "C" case 80 ...89: rank "B" case 90 ...100: rank "A" default: rank = "Invalid" }
用switch写分支替换if else
符攀飞 符攀飞
大约 3 年前
230

扫描下方二维码手机阅读文章

0 0