Created
May 31, 2017 08:03
-
-
Save hmhmsh/016582e6f9d88c9ec309035b1f9d9936 to your computer and use it in GitHub Desktop.
Extension of Swift like Kotlin
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
protocol Kotlin {} | |
extension Kotlin { | |
func lets<R>(_ closure: (Self) -> R) -> R { | |
return closure(self) | |
} | |
func apply(closure: (Self) -> Void) -> Self { | |
closure(self) | |
return self | |
} | |
} | |
extension Int: Kotlin {} | |
extension NSObject: Kotlin {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment