Make objects returned from the functions mutable to enable chain methods #11616
avitkauskas
started this conversation in
Ideas
Replies: 1 comment
-
This would be cool to have and readable too => |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Now this would not work:
because
sort()
requires mutable receiver.You have to do:
I think it would be good if objects (structs, arrays, primitives) returned from the funtions would be treated as mutable by compiler until they are assigned to some immutable variable.
This way it would enable method chaining independently of the mutability of the receiver of the method.
Could it be that method returns an immutable object (like the same immutable receiver it works on), and then this proposed change would allow to change the immutable object (that should never happen)?
Is there some better way to enable that?
Indicating if the returned object can be mutated of not?
Beta Was this translation helpful? Give feedback.
All reactions