Created
August 31, 2020 07:42
-
-
Save monsoir/8a402657555f5d133e8be5a1174d3d4f to your computer and use it in GitHub Desktop.
Pipe operator in Swift
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
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