zokipirlo
04/08/2021, 1:32 PMprivate fun isGroupChatInfoExpired(groupChatInfo: GroupChatInfo): Boolean {
return Epoch.currentEpoch > (groupChatInfo.epoch ?: 0 + GROUP_CHAT_INFO_VALID_TIME) //epoch is nullable
}
This is always true
. To fix the problem`groupChatInfo.epoch ?: 0` must be in parenthesis like:
private fun isGroupChatInfoExpired(groupChatInfo: GroupChatInfo): Boolean {
return Epoch.currentEpoch > ((groupChatInfo.epoch ?: 0) + GROUP_CHAT_INFO_VALID_TIME) //epoch is nullable
}
Is it possible to show some warning in IntelliJ (Android Studio) that this will possibly have a wrong evaluation?elizarov
04/08/2021, 2:44 PMsomething ?: a + b
, then I'll have to fix it to something ?: (a + b)
which does not look very nice to my taste.zokipirlo
04/08/2021, 2:53 PMDerek Peirce
04/09/2021, 4:28 AMorIfNull
(or better named) so that this would be groupChatInfo.epoch.orIfNull(0)
, so that the ()
go just around the replacement value instead of also in front of groupChatInfo
.elect
04/10/2021, 2:41 PM