Skip to content

Instantly share code, notes, and snippets.

@ToJans
Last active December 22, 2015 21:49
Show Gist options
  • Save ToJans/6536125 to your computer and use it in GitHub Desktop.
Save ToJans/6536125 to your computer and use it in GitHub Desktop.
We REALLY need a pipe operator in Erlang
Cargo = start_a_cargo(),
Cargo_1 = cargo:specify_new_route(Cargo_1, a_route_specification()),
Cargo_99 = cargo:assign_to_route(Cargo_2, an_itenerary_that_does_not_match_the_route_specification())
?assertEqual(misrouted, cargo_delivery:routing_status(Cargo_99)),
stop_a_cargo(Cargo_99).
%% A half-assed pipe function, not sure whether this is beter
Cargo = pipe(start_a_cargo(),
[ {cargo, specify_new_route, [a_route_specification()]},
{cargo, assign_to_route, [an_itenerary_that_does_not_match_the_route_specification()]}
]).
?assertEqual(misrouted, cargo_delivery:routing_status(Cargo)),
stop_a_cargo(Cargo).
Cargo = pipe(start_a_cargo(),[
fun(X) -> cargo:specify_new_route(X, a_route_specification()) end,
fun(X) -> cargo:assign_to_route(X, an_itenerary_that_does_not_match_the_route_specification()) end
]),
?assertEqual(misrouted, cargo_delivery:routing_status(Cargo)),
stop_a_cargo(Cargo).
cargo = start_a_cargo()
|> Cargo.specify_new_route(a_route_specification())
|> Cargo.assign_to_route(an_itenerary_that_does_not_match_the_route_specification())
assert :misrouted == Cargo.Delivery.routing_status(cargo)
stop_a_cargo(Cargo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment