rook
05/24/2017, 5:08 PMremote.foo != null && remote.foo != local.foo
I’m trying to simplify it to something like remote.foo != local.foo ?: false
but it seems like the elvis operator can’t be used that waykingsley
05/24/2017, 5:40 PMremote?.foo != local.foo
remote?.let { it.foo != local.foo } ?: false
rook
05/24/2017, 5:43 PMlocal
and remote
are non-null, but in either case foo
is nullable. I need the entire check to default to false
if remote.foo
is null without having the entire separate clause to check itlet
, but it ends up being about the same amount of characters 😓kingsley
05/24/2017, 5:52 PMfun checkFoo(remote: Bar, local: Bar) : Boolean {
val remoteFoo = remote.foo ?: return false
return remoteFoo != local.foo
}
rook
05/25/2017, 1:25 PM