Lazy Lambda not be recognised to a certain extent

class FuelTank (
    var lowFuel: Boolean = false,
    var currentlevel: Double = 0.0,
    var minFuel : Double = currentlevel * 10 / 100)
    var level = Delegates.vetoable(0) {
        _, _, new ->
        if (new < minFuel ) {
            true
        } else {
            false
        }
    }

minFuel is not be recognised by the lazy lambda. Please help.

You’re missing an { at the end of the constructor parameters to start the class body. And likewise you need an extra } at the end of your block

Also

if (something) {
  true
} else {
  false
}

is the same as something

1 Like

You are right now. I thought the opposite.

1 Like