Skip to content

Instantly share code, notes, and snippets.

@lamlv2305
Last active January 5, 2018 05:47
Show Gist options
  • Save lamlv2305/63911d887e2111c9295309ec0054b38e to your computer and use it in GitHub Desktop.
Save lamlv2305/63911d887e2111c9295309ec0054b38e to your computer and use it in GitHub Desktop.
[SWIFT 4.0] Forward Pipe Operator
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