Skip to content

Instantly share code, notes, and snippets.

@KinoAR

KinoAR/PipeRest.hx

Last active Apr 21, 2021
Embed
What would you like to do?
Haxe Simple Pipe Example
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;
}
@KinoAR

This comment has been minimized.

Copy link
Owner Author

@KinoAR KinoAR commented Apr 21, 2021

You can try out the example pipe here:

https://try.haxe.org/#082513ef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment