Skip to content

Instantly share code, notes, and snippets.

@rjchatfield
Created July 21, 2014 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjchatfield/3b7052077d58f4143170 to your computer and use it in GitHub Desktop.
Save rjchatfield/3b7052077d58f4143170 to your computer and use it in GitHub Desktop.
Where are the Enums?
/**
* 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