I use Android Studio Hint to display the type of a variable.
In Code A, the Hint of a is displayed as MutableState<Sections>, you can see Image A.
And the Hint of currentSection is displayed as Sections, you can see Image B, I think it should be MutableState<Sections>, right?
Code A
val a = rememberSaveable { mutableStateOf(tabContent.first().section)}
val (currentSection, updateSection) = rememberSaveable {
mutableStateOf(tabContent.first().section)
}
CodePudding user response:
a and currentSection was expected to have different data type.
currentSection is assigned by using destructuring declaration
val (currentSection, updateSection) = rememberSaveable {
...
}
In jetpack compose, you can create state in multiple ways
- val mutableState = remember { mutableStateOf(default) }
- var value by remember { mutableStateOf(default) }
- val (value, setValue) = remember { mutableStateOf(default) }
You can also check in the documentation


