hmhmsh
5/31/2017 - 8:03 AM

Extension of Swift like Kotlin

Extension of Swift like Kotlin

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 {}