What’s difference between “= remember” and ” by remember” (Kotlin, Jetpack Compose)

It is just for convenience, to shortify syntax. By using delegate (by keyword) you can skip relating to value because it is done under the hood.

In the documentation you can read

There are three ways to declare a MutableState object in a composable:

val mutableState = remember { mutableStateOf(default) }
var value by remember { mutableStateOf(default) }
val (value, setValue) = remember { mutableStateOf(default) }

These declarations are equivalent, and are provided as syntax sugar
for different uses of state. You should pick the one that produces the
easiest-to-read code in the composable you’re writing.

Cheers

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)