Variables can change. Yes, when you first declare the variable you initialize it to true
. But later you set ordenado
to false
. So why should it keep it’s original value. If you don’t want it to change you can declare it as a val
(value). That means it can only be set once, so the line ordenado = false
would create an compiler error.