swift - switch case 加大括号出现:Closure expression is unused 编译错误

light-ios

2018-04-04T11:24:05Z||2018-04-04T11:24:05Z

结论就是 swift 里 switch-case 不需要加大括号,也不用 break,case 和 case 之间会自动间隔。

let someCharacter: Character = "z"
switch someCharacter {
case "a":
    print("The first letter of the alphabet")
case "z":
    print("The last letter of the alphabet")
default:
    print("Some other character")
}
// Prints "The last letter of the alphabet"