Call an object method: Difference between revisions
m
→{{header|Ecstasy}}
mNo edit summary |
|||
Line 359:
Calling a method or function in Ecstasy follows roughly the same conventions as in Java and C#, but in order to prevent certain types of bugs, Ecstasy explicitly disallows calling a function <i>as if it were a method</i>.
<syntaxhighlight lang="java">
module CallMethod {
{▼
/**
* This is a class with a method and a function.
*/
const Example(String text) {
@Override
String toString()
return $"This is an example with text={text}";
static Int oneMoreThan(Int n)
return n+1;
}
void run() {
@Inject Console console;
Line 407 ⟶ 402:
val func4 = &func3(13); // <-- type: function Int()
console.print($"Calling a fully bound function: {func4()}");
}
}
</syntaxhighlight>
|