That doesn't really matter if you're not using it ...
# getting-started
k
That doesn't really matter if you're not using it as an expression, but the last statement in a lambda always is.
b
What would be the best way here? Two separate lambdas?
Copy code
if (isExisting) {
            context.database.use {
                update(RadarItem.TABLE, values, "id = ?", arrayOf(radar.id.toString()))
            }
        } else {
            context.database.use {
                insert(RadarItem.TABLE, RadarItem.C_TITLE, values)
            }
        }
Looks pretty bad though
k
Well there's no real problem, it's just a triggerhappy idea warning.
Maybe there's a way to surpress it?
b
There is a suppression flag, but I ended up with casting the update value to long.
update(RadarItem.TABLE, values, "id = ?", arrayOf(radar.id.toString())).toLong()
I guess if the conditional's result is not used, maybe it should not throw a warning like this. But that's the IDE's problem.
k
Right, problem is that it is used: it's the return value of the lambda.
b
but if the lambda result is not assigned to anything? (am I understanding correctly, that the lambda is the use{} block?)
k
Well of course we know it isn't used, but that would require the compiler to look into the
use
function and even further to the surrounding code, which it currently doesn't do.
👍 1