Hacker News new | ask | show | jobs
by namelezz 3321 days ago
var = variable (can vary/change)

val = value (constant)

What can be mistaken?

4 comments

Pet 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.
At a quick glance one might mistake var for val since they're only one letter apart. The definitions do make sense though.
I don't find it to be confusing but you'd get more autocomplete help if let was used for constants.

l => let

v => var

Very good point. Fortunately, it's only one keystroke saved.
One 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.

It could be two if it inserted the space for you!
The look?