Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/Call-a-function/Ecstasy/call-a-function-8.ecstasy
Normal file
16
Task/Call-a-function/Ecstasy/call-a-function-8.ecstasy
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// 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()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue