parameter
Declare a parameter with the given arguments.
val letter by parameter('a'..'z')
Content copied to clipboard
inline fun <T> ParameterizeScope.parameter(crossinline lazyArguments: LazyParameterScope.() -> Sequence<T>): ParameterizeScope.Parameter<T>(source)
inline fun <T> ParameterizeScope.parameter(crossinline lazyArguments: LazyParameterScope.() -> Iterable<T>): ParameterizeScope.Parameter<T>(source)
Declares a parameter with the given lazyArguments. The arguments are only computed the first time the parameter is used, and not at all if used.
This parameter
function is useful to avoid computing the arguments every iteration. Instead, these arguments will only be computed the first time the parameter is used.
val evenNumberSquared by parameter {
numbers
.filter { it % 2 == 0 }
.map { it * it }
}
Content copied to clipboard
Restrictions
The lazyArguments block should not have side effects. Since it's not run every iteration, side effects could make the execution different from future iterations, breaking parameterize's determinism assumption.