RosettaCodeData/Task/Nested-function/Ecstasy/nested-function.ecstasy
2023-07-01 13:44:08 -04:00

16 lines
389 B
Text

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(". "));
}
}