RosettaCodeData/Task/Singleton/Ecstasy/singleton.ecstasy

16 lines
328 B
Plaintext

module test {
static service Singleton {
private Int counter;
String fooHasBeenCalled() {
return $"{++counter} times";
}
}
void run() {
@Inject Console console;
for (Int i : 1..5) {
console.print($"{Singleton.fooHasBeenCalled()=}");
}
}
}