Guest User

Untitled

a guest
May 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. /// Wind speed with direction
  2. enum WindSpeed {
  3. case north(Double)
  4. case east(Double)
  5. case south(Double)
  6. case west(Double)
  7. }
  8.  
  9. let direction = WindSpeed.north(3.6)
  10.  
  11. // Switch with value binding before matching pattern
  12. switch direction {
  13. case let .north(speed):
  14. print(speed)
  15. default:
  16. print("default")
  17. }
  18.  
  19. // Switch with value binding inside matching pattern
  20. switch direction {
  21. case .north(let speed):
  22. print(speed)
  23. default:
  24. print("default")
  25. }
Add Comment
Please, Sign In to add comment