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 {
|
fun encodeAlertSet(alertSet: EnumSet<AlertType>): Byte =
|
||||||
var out = 0
|
alertSet.fold(0,
|
||||||
alertSet.forEach { slot ->
|
{ out, slot ->
|
||||||
out = out or (slot.value.toInt() and 0xff)
|
out or (slot.value.toInt() and 0xff)
|
||||||
}
|
|
||||||
return out.toByte()
|
|
||||||
}
|
}
|
||||||
|
).toByte()
|
||||||
}
|
}
|
Loading…
Reference in a new issue