Created
July 21, 2014 11:45
-
-
Save rjchatfield/3b7052077d58f4143170 to your computer and use it in GitHub Desktop.
Where are the Enums?
This file contains 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
/** | |
* Functions that: | |
* return multiple functions, and also | |
* contain Structs that: | |
* contain Classes that: | |
* contain Functions. | |
*/ | |
func plusOneFunctions () -> (a:(Int) -> Int, b:(Int) -> Int) { | |
struct MyStruct { | |
class MyClass { | |
func myPlusOneFunction (num:Int) -> Int { | |
return num + 1 | |
} | |
} | |
let aClass = MyClass() | |
} | |
return (MyStruct().aClass.myPlusOneFunction, { $0 + 1 }) | |
} | |
let (plusFuncA, plusFuncB) = plusOneFunctions() | |
let plusFuncs = plusOneFunctions() | |
println("plusFuncA == plusFuncB : \( plusFuncA(1) == plusFuncB(1) )") | |
println("plusFuncs.a == plusFuncs.b : \( plusFuncs.a(1) == plusFuncs.b(1) )") | |
/** | |
* Where are the enums? | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment