3 ms·
They are, but you use ?-: instead of if-else
by paulddraper 3y ago
They are, but you use ?-: instead of if-else
- Akronymus 3y agoThat still doesn't make all blocks expressions. In f# everything is an expression and it simplifies the language a lot. The last value in a block is considered the value "return" value of the whole block, which has the knockon effect of getting rid of most returns, allows you to check an if/else to return the same type and such. This also works in conjunction with the type inference, so you get an error when you try to return a string in one branch and an int in another.
- paulddraper 3y agoI understand. Scala is the same. JavaScript has a limited form of that via the comma operator.