Last active
January 8, 2016 22:45
-
-
Save getmetorajesh/e287a00580f1a46b83d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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