17 lines
513 B
Plaintext
17 lines
513 B
Plaintext
// 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()}");
|
|
}
|
|
}
|
|
}
|