Scope

object Scope

Utility for executing blocks of code within contexts of objects in Java.

Optionally possible in Kotlin via scope functions.

Author

Lucas Bubner, 2025

Since

7.0.0

Functions

Link copied to clipboard
fun <T> apply(obj: T, block: Consumer<T>): T

Calls the specified function block with obj value as its argument and returns obj.

Link copied to clipboard
fun <T> applySafe(obj: T?, block: Consumer<T>): T?

Calls the specified function block with obj value as its argument and returns obj.

Link copied to clipboard
fun <T, R> let(obj: T, block: Function<T, R>): R

Calls the specified function block with obj value as its argument and returns its result.

Link copied to clipboard
fun <T, R> letSafe(obj: T?, block: Function<T, R?>): R?

Calls the specified function block with nullable obj value as its argument and returns its result.

Link copied to clipboard
fun run(block: Runnable)

Calls the specified function block and returns no result.

fun <T> run(block: Supplier<T?>): T?

Calls the specified function block and returns its nullable result.