Can anyone explain why the method below is compiling without any error message? I expected a dead code warning or something like that. Is there a reason why it compiles?
def somethingAfterReturn(): Int = {
println("That is ok..");
return 1
println("WTF is going on here?");
3
}
First, try this:
no errors, right?
Then, try this:
By default, Scala ignore unreachable code.