3 ms·
How so?
by saagarjha 9y ago
How so?
- rbonvall 9y agoI'm sure he means `val` as in Scala, where it is used to define a name that cannot be rebound: val x = 1 var y = 2 x = 3 // compile error y = 4 // ok It makes it easier to read code since you don't have to keep track of changes in your head.
- saagarjha 9y agoYes, this would be a nice addition, but I think final var might be able to stand in for it as of right now. One issue if it was adopted might be that “final” in Java doesn’t actually mean a whole lot, since there aren’t a lot of value types where mutation can be detected.
- blattimwind 9y agoOr as in Kotlin.
- krotton 9y agoI guess the parent meant val as synonymous to final var, i.e. immutable.
- saagarjha 9y agovar, let, val, there are so many of these and they all mean different things in different languages! It makes it hard to talk about them.