2 ms·
It's a bit of a semantic distinction isn't it? In practice what it means is that you add semicolons to the end of almost every line of imperative code in a blo
by skohan 7y ago
It's a bit of a semantic distinction isn't it? In practice what it means is that you add semicolons to the end of almost every line of imperative code in a block, and you leave the semicolon off the last line and this becomes your return value implicitly (without the use of a return keyword).
- steveklabnik 7y agoIt is a semantic distinction, because "everything is an expression" and "implicit returns" have different semantics. Thinking of them as implicit returns leads people to believe they can write code like fn foo(x: bool) -> i32 { if x { 5 } // more code and then they're confused when this doesn't work.