Proposed rule: Use delegation of mutable state rather than variable state value #376
VirtualParticle
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
I'm not sure we could make a strongly defined enough lint to make this practical. For example, it's legal to write |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Storing the actual state object in a variable like this:
should be avoided in favor of
In the first example, there's no reason that the field
x
should actually be mutable since it's thevalue
property within it that should be changed. Even in this example:where
x
is properly immutable, it's still probably preferred that the delegation syntax be used just because it's cleaner. I and the official compose docs seem to mostly prefer the delegation syntax, but not everyone might agree.Beta Was this translation helpful? Give feedback.
All reactions