compileFunction1OrNull

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

Tries to compile a given string expression into a single-parameter function. Returns the compiled function if successful, or null if an error occurs during compilation. Errors are handled using the provided onError callback.

Return

A single-parameter function that takes an argument of type T0 and evaluates the expression to return a result of type R, or null if the compilation fails.

Parameters

T0

The type of the single parameter that will be passed to the compiled function.

R

The return type of the compiled function.

expression

The string representation of the expression to be compiled.

parameter0

The name of the required parameter in the expression.

constants

A lambda function to resolve constants in the expression by their names. Defaults to a function returning null for all names.

functions

A set of function extensions that can be used within the expression. Defaults to an empty set.

onError

A callback function that will be invoked when an error occurs during compilation. The error is passed to this function.