Last active
January 5, 2018 05:47
-
-
Save lamlv2305/63911d887e2111c9295309ec0054b38e to your computer and use it in GitHub Desktop.
[SWIFT 4.0] Forward Pipe Operator
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
infix operator |>: AdditionPrecedence | |
func |> <T, U>(value: T, function: ((T) -> U)) -> U { | |
return function(value) | |
} | |
func pow(_ value: Int) -> String { | |
return "ahihi \(value * value)" | |
} | |
let k = 3 |> pow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment