Last active
February 11, 2017 04:20
-
-
Save saoudrizwan/6335737d7f6b56dcc7fac8d58e7a0f0f to your computer and use it in GitHub Desktop.
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
extension Int { | |
func doMath(_ transform: ((Int) -> (Int)) ) -> (Int) { | |
return transform(self) | |
} | |
} | |
let doubled = 5.doMath { (number) -> (Int) in | |
return number * 2 | |
} | |
print(doubled) // 10 | |
let minusOne = 8.doMath { $0 - 1 } | |
print(minusOne) // 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment