2 ms·
Maybe I'm misunderstanding you, but why wouldn't it work in an expression based language? Isn't if let pat = expr1 { expr2 } just syntactic sugar for ma
by tpush 11y ago
Maybe I'm misunderstanding you, but why wouldn't it work in an expression based language?
Isn't
if let pat = expr1 { expr2 }
just syntactic sugar for
match expr1 {
pat => { expr2 }
_ => { }
meaning the type of expr2 must be unit, and thusly if let is always of unit type?
- CuriousSkeptic 11y agoGranted. But a unit expression is only useful for its side effect so I guess I put that in the gray area between paradigms, not really in the spirit of only evaluating expressions. Which brings us back the point of my comment: It's almost certainly a bad idea.
- sedatk 11y agoThe unhandled case is explicitly mentioned in the latter though.