error in if return in Scala
if(a>4) { val result = a } this is creating a second val named result that is only scoped (visible) inside the if block, so the return statement always returns the value defined on line 2. A val can not be reassigned so you would need to use a var if you needed to change … Read more