What does let 5 = 10 do? Is it not an assignment operation?

When you say

let 5 = 10

it’s not a redefinition of 5, it’s a pattern matching, the same which occurs when you say

foo 5 = undefined
 ... foo 10 ...

The pattern simply fails if it’s ever matched.

In let-expressions the match is lazy. This means the match is only being done when a variable bound by it is evaluated. This allows us to write things like

 let foo = undefined in 10

In your expression, no variable is bound, so the pattern is never matched.

Arguably such patterns with no variables make no sense in let-bindings and should be detected by the compiler, but the language doesn’t forbid them.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)