Skip to content

Instantly share code, notes, and snippets.

@Hadevs
Created December 15, 2018 14:28
Show Gist options
  • Save Hadevs/550ae1db5fd88a6bcb9ed7a61b28a901 to your computer and use it in GitHub Desktop.
Save Hadevs/550ae1db5fd88a6bcb9ed7a61b28a901 to your computer and use it in GitHub Desktop.
// 1.
enum Animal {
case cat
case dog
case foo
case bar
}
let count = 10
let animal = Animal.cat
switch animal {
case .cat:
print("I am kitty cat")
case .cat where count < 5:
print("I am kitty cat with count less than 5")
default: break
}
// 2.
for i in 0..<count where animal == .cat {
print(animal, i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment