Kotlin- Jetpack Owl中的未知语法示例
试图找到有关如何在懒惰列中选择多个项目的方向,我在OWL JetPack组成示例(onboarding.kt)中找到了以下代码。
...
val (selected, onSelected) = remember { mutableStateOf(false) }
...
即使我能够自己使用代码,也无法解码该Val声明的语法。 我在kotlinlang.org网站上找不到任何东西(我发现最近的主题是关于破坏声明的)。 有人可以帮助我理解它和/或将我指向相关文档吗?
trying to find some direction on how to select multiple items in a lazy column, I have found the following code in Owl Jetpack Compose example (Onboarding.kt).
...
val (selected, onSelected) = remember { mutableStateOf(false) }
...
Even if I'm able to use the code by myself, I really not able to decode the syntax of this val declaration.
I wasn't able to find anything in kotlinlang.org site (the nearest topic I've found is about Destructuring declarations).
Could someone help me to understand it and/or point me to relevant documentation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您提到的那样,该语法正在破坏它,该语法是
指靶向类的2个组成部分的expclicity。
(val num1:int,val num2:int)= pair(1,2)
是一个具有mutableState的
示例,您需要添加
t
type type和一个将t作为t作为参数和返回单元。内部
snapshotimpl
mutableState的源代码,因此您使用此lambda设置的任何东西都分配给值
t
This syntax is Destructuring as you mentioned in question which is expclicitly as
Which requires 2 components of targetted class.
(val num1:Int, val num2:Int) = Pair(1,2)
is an exampleWith MutableState
You need to add
T
type and a lambda that takes T as param and returns unit.And inside
SnapshotImpl
source code of MutableState it's used asso anything you set using this lambda is assigned to value
T