ScopeFunctionsX<T extends Object> extension

Kotlin-style scope functions available on every non-null value.

These let you keep expression chains flat instead of introducing intermediate local variables.

on
  • T

Methods

also(void action(T it)) → T

Available on T, provided by the ScopeFunctionsX extension

Runs action with this value and returns the value unchanged.
asOrNull<R>() → R?

Available on T, provided by the ScopeFunctionsX extension

Safe cast: returns this value as R, or null if it is not an R.
let<R>(R transform(T it)) → R

Available on T, provided by the ScopeFunctionsX extension

Applies transform to this value and returns its result.
takeIf(bool predicate(T it)) → T?

Available on T, provided by the ScopeFunctionsX extension

Returns this value when predicate holds, otherwise null.
takeUnless(bool predicate(T it)) → T?

Available on T, provided by the ScopeFunctionsX extension

Returns this value when predicate fails, otherwise null.