var directionToHead =CompassPoint.West directionToHead = .East
使用switch语句匹配枚举值
1 2 3 4 5 6 7 8 9 10 11 12
directionToHead = .South switch directionToHead { case .North: println("Lots of planets have a north") case .South: println("Watch out for penguins") case .East: println("Where the sun rises") case .West: println("Where the skies are blue") } // prints "Watch out for penguins"