compileFunction2OrNull

fun <T0, T1, R> compileFunction2OrNull(expression: String, parameter0: String, parameter1: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY, onError: (Throwable) -> Unit = { }): (T0, T1) -> R?(source)

Attempts to compile a string expression into a lambda function with two parameters, returning null if an error occurs during compilation.

This function is a safe wrapper around compileFunction2, catching any exceptions that may be thrown during the compilation process. If an error occurs, the provided onError callback is invoked with the exception, and the function returns null.

Return

A lambda function that takes two parameters of types T0 and T1 and returns a result of type R if the compilation is successful. Returns null if an error occurs during compilation.

Parameters

T0

The type of the first parameter.

T1

The type of the second parameter.

R

The return type of the resulting lambda function.

expression

The string expression to compile.

parameter0

The name of the first parameter in the expression.

parameter1

The name of the second parameter in the expression.

constants

A lambda function that provides constant values for variables by name. Defaults to returning null for all names.

functions

The custom functions available in the context of the expression. Defaults to an empty set of functions.

onError

A callback invoked with the exception if an error occurs during compilation. Defaults to an empty function.