4 ms·
var = variable (can vary/change) val = value (constant) What can be mistaken?
by namelezz 9y ago
var = variable (can vary/change)
val = value (constant)
What can be mistaken?
- kibwen 9y agoPet peeve here: "variable" and "mutable" aren't concepts that are useful to conflate. Imagine a function that takes a variable and prints its value to the command line. There's no mutation of the variable going on, so the variable is immutable. And yet it's still a variable because each time that you call this function, the value that gets printed is allowed to vary. This is distinct from a constant, where each time you call the function the value of a constant must be the same.
- thatswrong0 9y agoAt a quick glance one might mistake var for val since they're only one letter apart. The definitions do make sense though.
- melling 9y agoI don't find it to be confusing but you'd get more autocomplete help if let was used for constants. l => let v => var
- dajohnson89 9y agoVery good point. Fortunately, it's only one keystroke saved.
- NinoScript 9y agoIt could be two if it inserted the space for you!
- melling 9y agoOne keystroke, not two? I type l<tab> in Xcode then I'm typing in the variable name. You'll have to arrow down if it's the wrong one then hit return. You can argue that it's really not much extra work but it all adds up. Especially when you try to code on a tablet, which I find myself doing occasionally.
- h1d 9y agoThe look?