I think it would be worth adding a use case that shows why you don’t just assign them to the correct value in the first place
Rob Elliot
12/10/2020, 4:41 PM
But FWIW, typically multi variable declaration is considered poor style in Java, so Kotlin doesn’t allow it; and there’s a fairly strong bias against reassignment in kotlin (favour
val
over
var
), so I’d be surprised if this got much traction. No harm asking though.
g
GarouDan
12/11/2020, 12:02 AM
About the first statement, yes, indeed I have a good example for that. There are some kind of recursive problems, for coding challenges for example, that this kind of behavior is needed.
GarouDan
12/11/2020, 12:04 AM
About the second one I disagree. Actually Java is too old fashionable these days to dictate the way we write code. And the code there is much less about val or var, but more about the possibility of multiple assignments and swapping. Var was used, of course, because the values need to be swapped and because of that the values need to be mutable.