Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Wind speed with direction
- enum WindSpeed {
- case north(Double)
- case east(Double)
- case south(Double)
- case west(Double)
- }
- let direction = WindSpeed.north(3.6)
- // Switch with value binding before matching pattern
- switch direction {
- case let .north(speed):
- print(speed)
- default:
- print("default")
- }
- // Switch with value binding inside matching pattern
- switch direction {
- case .north(let speed):
- print(speed)
- default:
- print("default")
- }
Add Comment
Please, Sign In to add comment