2 ms·
Right, though I was thinking of other examples of functional match style and returning a value. As seen in in Haskell, F# Rust etc. e.g. https://doc.rust-lang.
by SideburnsOfDoom 9y ago
Right, though I was thinking of other examples of functional match style and returning a value. As seen in in Haskell, F# Rust etc.
e.g. https://doc.rust-lang.org/book/second-edition/ch06-02-match.html https://doc.rust-lang.org/book/second-edition/ch06-02-match....
So value_in_cents can return a value of 1, 5, 10 or 25.
Saying that it "does not have a return statement" might be truish - but the fact that the "return" keyword is not needed to return values is just syntax.
Saying that there's no early return / multiple exit points is not so much. To my eye there are 4 places where that function can return a value. And the cases might not be simple numbers making the whole thing an expression, later examples on that page show how the cases can differ in side-effects.