Hacker News new | ask | show | jobs
by mkesper 3323 days ago
Not OP, but why do you need the 'let' at all? Why not x = 7 mut y = 3 ?
2 comments

Because it's a bit too error-prone:

   mut listOfLeftHandedOralHygienistsInKazakhstan = getThem()
   // several lines later
   listOfLeftHandedOralHygienistsInKazahkstan = getThemAgain()
You thought you were reassigning the mutable variable, but you actually created a different immutable variable.

This can be prevented by having different operators for assignment and re-assignment. Some languages do that: in OCaml / F#, re-assignments use '<-' while declarations use 'let (mutable) x =' (they can't drop the 'let' because they use '=' as the Boolean equality operator).

... and whoops, the next thing you know your left handed oral hygienist has apocryphally crashed into Venus.

https://en.wikipedia.org/wiki/Mariner_1

My sibling is correct, but also, there are grammar issues with doing it that way. They're not insurmountable, but much, much simpler with the let.