Review: use fold in AlertUtil.encodeAlerts

This commit is contained in:
Bart Sopers 2021-02-28 19:28:52 +01:00
parent 8e7e2450ae
commit 8e7b1d3612

View file

@ -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()
} }