Skip to content

Instantly share code, notes, and snippets.

@getmetorajesh
Last active January 8, 2016 22:45
Show Gist options
  • Select an option

  • Save getmetorajesh/e287a00580f1a46b83d7 to your computer and use it in GitHub Desktop.

Select an option

Save getmetorajesh/e287a00580f1a46b83d7 to your computer and use it in GitHub Desktop.
1. you can print enums
enum Animals {
case Dog, Cat, Troll, Dragon
}
let a = Animals.Dragon
print(A)
2. Associated values in Enums
enum Either<T1, T2> {
case First(T1)
case Second(T2)
}
3. Recursive Enums-
Enums in swift are simply algeabraic data types
enum Tree<T> {
case Leaf(T)
indirect case Node(Tree, Tree)
}
4. Do Statement - to define an explicit scope
imp in error handling
do{
let a = Animals.Troll
...
}
instead of do while use repeat
repeat {
...
}
5. Option Sets
viewAnimationOptions = [.Repeat, .CurveEaseIn, .TransitionCurlUp]
viewAnimationOptions = []
if viewAnimationOptions.contains(.TransitionCurlUp) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment