bbaldino
01/06/2020, 5:23 PMbezrukov
01/08/2020, 11:26 AM@CheckResult
is probably what are you looking for - https://developer.android.com/reference/android/support/annotation/CheckResultbbaldino
01/08/2020, 5:53 PMkyleg
01/08/2020, 8:20 PMbbaldino
01/08/2020, 8:20 PMfun Byte.putBit(bitPos: Int, isSet: Boolean): Byte {
return if (isSet) {
(this.toInt() or (0b10000000 ushr bitPos)).toByte()
} else {
(this.toInt() and (0b10000000 ushr bitPos).inv()).toByte()
}
}
it would be easy for someone to call myByte.putBit(1, true)
and think it would be modified in place, but actually it returns the new value. i'm looking for a way similar to 'nodiscard' in c++ where i can generate a warning of some kind in this scenario