() and {} (invoke) operators

The left-associative, unary () and {} operators are used to invoke methods and instantiate classes

Usage

print("hello, world!");       // positional style
print{                        // named-arguments style
    line="hello, world";
};
MyClass instance = MyClass(); // invoking a class to get an instance

Description

For detailed information see the reference documentation on [method invocation] doc coming soon at (../../../reference/expression/method-invocation) and [class invocation] doc coming soon at (../../../reference/expression/class-invocation).

Definition

The () and {} operators are primitive.

Polymorphism

The () and {} operators are not polymorphic.

Type

The result type of the invocation operator expressions is the return type of the callable type of the left hand operand.

See also

  • [spread invoke] doc coming soon at (../spread-invoke) for calling a Callable[]
  • API documentation for [Callable] doc coming soon at (../../ceylon.language/Callable)
  • operator precedence in the language specification