RosettaCodeData/Task/Call-a-function/Ecstasy/call-a-function-9.ecstasy

20 lines
734 B
Plaintext

module PartialApplication {
void foo(String s, Int i, Dec d) {
@Inject Console console;
console.print($"inside call to foo({s=}, {i=}, {d=})");
}
void run() {
// note that the "&" obtains the reference to the function, and suppresses the
// invocation thereof, so it is *allowed* in all three of these cases, but it
// is *required* in the third case:
function void(String, Int, Dec) unbound = foo; // or "foo(_, _, _)"
function void(String, Dec) partBound = unbound(_, 99, _);
function void() allBound = &partBound("world", 3.14);
unbound("nothing", 0, 0.0);
partBound("hello", 2.718);
allBound();
}
}