Android Studio doesn't `rollButton.text = "Press"`...
# codingconventions
e
Android Studio doesn't
rollButton.text = "Press"
, as shown by the underscore under `text`:
What's wrong with the code (besides the string literal)? When I take Android Studio's suggestion to convert assignment to assignment expression, it converts the code to this monstrosity:
Copy code
"Press".also { rollButton.text = it }
The other suggestion is to add method contract to
setText
.
FTR, I found out elsewhere that the underline just means that
text
is a
var
, not that anything is the matter.
g
underscore it’s standard syntax highlighting in kotlin for mutable variables, properties The goal of it not only show that it mutable, but partially discurage it
✔️ 1
about “apply” block, it’s not a suggestion, it’s called “quickfix”, it’s just a context action available for this line of code, for example if you press Alt+Enter on forEach you will see “replace with for loop”, so it’s not really a suggestion, but some shortcuts for common idioms
✔️ 1