klyn.reflection.Invocable.operator
method
public operator ()(args as Object[]) as ReturnType throws Exception
Description

Direct call operator.

The compiler translates f(args...) to a reflective invocation with an Object[]. This convenience does not turn Invocable into a statically typed function signature.

Parameters
ParameterDescription
argsArguments as Object array.
Returns

Result of type ReturnType.

Throws
  • Exception if invocation fails.
Example
import klyn.reflection

f = eval("def twice(x as Int) as Int:\n    return x * 2")
if f is Invocable<Int>:
    print(f(21))    # 42