enum Direction {
case north
case south
case east
case west
}
等价:
enum Direction {
case north, south, east, west
}
var dir = Direction.west
dir = Direction.east
dir = .north
print(dir) // north
switch dir {
case .north:
print("north")
case .south:
print("south")
case .east:
print("east")
case .west:
print("west")
}
Swift枚举
最新推荐文章于 2024-08-23 22:06:46 发布