Vitali Plagov
03/31/2023, 8:25 AMprivate fun assertSomething() {
var count = 2
if (count == 0) {
error("field is empty")
}
runCatching {
doSomeChecks()
}.onFailure {
refresh()
count--
assertSomething()
}
}
And IntelliJ IDEA has an inspection warning on if (count == 0)
, saying that the condition is always false
.
I think it's a wrong warning, no? The count
var will be equal to zero if the doSomeChecks()
will fail twice.Sam
03/31/2023, 8:27 AMcount
variable is local to each individual function call. If you call the function again you get a new count
with a new value.Vitali Plagov
03/31/2023, 8:28 AM