Last active
April 21, 2021 00:40
-
-
Save KinoAR/2bc31987b21266bb01894d5c7bf7bf03 to your computer and use it in GitHub Desktop.
Haxe Simple Pipe Example
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
import haxe.Rest; | |
function main() { | |
var result = pipe('A', | |
(val:String) -> val.toUpperCase(), | |
(val2:String) -> val2 += " " + "World"); | |
trace(result); //A World | |
} | |
//Dynamic Piping Function | |
function pipe<T>(val:T, ...fns:T->Any) { | |
for(fn in fns) { | |
val = fn(val); | |
} | |
return val; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can try out the example pipe here:
https://try.haxe.org/#082513ef