RosettaCodeData/Task/Call-a-function/Ecstasy/call-a-function-8.ecstasy
2023-07-01 13:44:08 -04:00

16 lines
513 B
Text

// Ecstasy does not have any built-in functions. However, there are two keywords
// ("is" and "as") that use a function-like syntax:
module IsAndAs {
Int|String foo() {
return "hello";
}
void run() {
@Inject Console console;
Object o = foo();
if (o.is(String)) { // <- looks like a function call
String s = o.as(String); // <- looks like a function call
console.print($"foo returned the string: {s.quoted()}");
}
}
}