Join Slack
Powered by
In the TextField composable code, I noticed it ann...
# compose
z
zt
11/11/2022, 5:26 AM
In the TextField composable code, I noticed it annotated the lambda for the decoration box with @Composable, however it works without it. Does the compiler do something different when it's there?
z
Zach Klippenstein (he/him) [MOD]
11/11/2022, 3:28 PM
You mean this?
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextField.kt;l=210;drc=ab08e07d4ba9c46eb461d2dd3e51549d6ad44707
It shouldn’t matter. I’m guessing that’s maybe leftover from an early time when the compiler wasn’t smart enough to infer that a lambda passed as a parameter marked composable should also be composable, but it is now.
z
zt
11/11/2022, 3:56 PM
That's probably it, wasn't sure if there was some intention behind annotating it
z
Zach Klippenstein (he/him) [MOD]
11/11/2022, 4:42 PM
AFAIK, that annotation is mostly useful for type _inference_:
Copy code
val myContent = @Composable { … }
5
Views
Open in Slack
Previous
Next