4 ms·
In my experience as someone whose been writing scala for a couple of years (which also uses val/var), it has 100% never been confusing or a problem.
by bxrxaxdx 9y ago
In my experience as someone whose been writing scala for a couple of years (which also uses val/var), it has 100% never been confusing or a problem.
- Cyph0n 9y agoI second this. Not to mention that you end up using val most of the time in practice, so there really is no confusion.
- whateveracct 9y agoscala-mode2 (which isn't close to an IDE) also highlights vars in red so it's extra hard to get mixed up :)
- opportune 9y agoYep. I think the names themselves are quite unambiguous to boot. A variable is something that varies in value, meaning it can be changed. A value is always that same value; 5 is never 6. Pretty straightforward if you ask me.
- wapz 9y agoI'm guessing the parent is just complaining that if you are reading code very fast (particularly if you're browsing repositories on your phone) it is hard to distinguish between "val" and "var."
- h1d 9y agoLet alone type them wrong on a tired night.
- thomastjeffery 9y agoThankfully that would be a simple compile-time error. The message might even be readable.
- darklajid 9y agoIf you type var and mean val - would there be any error? (I'm sure that this is just something you need to get used to, I'm merely trying to point out that this could be a silent typo/mistake)
- Larrikin 9y agoIn actuality it will be extremely obvious in the IDE and the developer would not make this error.
- thomastjeffery 9y agoif "val" is a constant, and you try to mutate it later, the compiler will tell you, "That ain't gonna happen."
- jpliska 9y agoIn many cases, you would get warnings when accessing a var that you don't get when accessing a val. Also, IntelliJ suggests converting to val if a var is never reassigned.
- dullgiulio 9y agoAs others said, not a problem if you are using an IDE (and a specific one.) Considering who authored the language, I am not surprised at all.
- dnautics 9y agoIt's even worse when your primary keyboard is Dvorak!