invoke

open fun invoke(target: T, args: Array<Any?> = emptyArray<Any?>()): R

Invokes the function on the specified target object with the given arguments. Uses FastInvoke.safeInvoke for proper exception handling and performance.

Return

the result of the function invocation

Parameters

target

the object on which to invoke the function

args

the arguments to pass to the function (empty array by default)

Throws

if the function invocation fails or throws an exception

Example usage:

val accessor = SimpleFunctionAccessor<MyClass, String>(MyClass::getName)
val instance = MyClass()
val result = accessor.invoke(instance) // calls instance.getName()