Review: use fold in AlertUtil.encodeAlerts
This commit is contained in:
parent
8e7e2450ae
commit
8e7b1d3612
1 changed files with 6 additions and 7 deletions
|
@ -19,11 +19,10 @@ object AlertUtil {
|
|||
}
|
||||
}
|
||||
|
||||
fun encodeAlertSet(alertSet: EnumSet<AlertType>): Byte {
|
||||
var out = 0
|
||||
alertSet.forEach { slot ->
|
||||
out = out or (slot.value.toInt() and 0xff)
|
||||
}
|
||||
return out.toByte()
|
||||
}
|
||||
fun encodeAlertSet(alertSet: EnumSet<AlertType>): Byte =
|
||||
alertSet.fold(0,
|
||||
{ out, slot ->
|
||||
out or (slot.value.toInt() and 0xff)
|
||||
}
|
||||
).toByte()
|
||||
}
|
Loading…
Reference in a new issue