Returning from functions before reaching the last statement can be done using "return", for example:
fn example() -> i32 {
if true {
return 1;
}
0 // this line is never reached
}
Is it possible to do something similar with block expressions? Example:
let foo = {
if true {
*something to exit with 1*
}
0 // this line is never reached
};
Thanks for any help.
P.S. I know in this simple example I could have used the "if-else" expression. I'm asking about block expressions in general, not this example in particular :)