4 ms·
Not OP, but why do you need the 'let' at all? Why not x = 7 mut y = 3 ?
by mkesper 9y ago
Not OP, but why do you need the 'let' at all?
Why not
x = 7
mut y = 3
?
- piaste 9y agoBecause 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).
- RegW 9y ago... and whoops, the next thing you know your left handed oral hygienist has apocryphally crashed into Venus. https://en.wikipedia.org/wiki/Mariner_1 https://en.wikipedia.org/wiki/Mariner_1
- steveklabnik 9y agoMy 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.