RosettaCodeData/Task/Nested-function/Ecstasy/nested-function.ecstasy

17 lines
389 B
Plaintext

module NestedFunction {
static String makeList(String separator) {
Int counter = 1;
function String(String) makeItem = item -> $"{counter++}{separator}{item}\n";
return makeItem("first")
+ makeItem("second")
+ makeItem("third");
}
void run() {
@Inject Console console;
console.print(makeList(". "));
}
}