Last active
January 7, 2020 17:22
-
-
Save saiday/8882853369486af49617c2be9cfb6ba8 to your computer and use it in GitHub Desktop.
instance method curried function
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
class C { | |
func printla(_ msg: String) { print(msg) } | |
func getPrinter(_ msg: String) -> (String)->() { return { msg in self.printla(msg) } } | |
} | |
let c = C() | |
let im = C.printla // im is of type (C)->(String)->(), | |
im(c)("who let the dogs out") // prints "who let the dogs out" | |
let sim = im(c) // sim is of type (String)->() | |
sim("me") // prints "me" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment