Skip to content

Instantly share code, notes, and snippets.

@monsoir
Created August 31, 2020 07:42
Show Gist options
  • Save monsoir/8a402657555f5d133e8be5a1174d3d4f to your computer and use it in GitHub Desktop.
Save monsoir/8a402657555f5d133e8be5a1174d3d4f to your computer and use it in GitHub Desktop.
Pipe operator in Swift
precedencegroup ForwardPipe {
associativity: left
higherThan: LogicalConjunctionPrecedence
}
infix operator |> : ForwardPipe
///Swift implementation of the forward pipe operator from F#
/// Used for better readibility when piping results of one function to the next ones.
/// More details here: https://goo.gl/nHzeS6
public func |> <T, U>(value: T, function: ((T) -> U)) -> U {
return function (value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment