io.youi.util.RangeGroup.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of youi-core_sjs0.6_2.13 Show documentation
Show all versions of youi-core_sjs0.6_2.13 Show documentation
Core functionality leveraged and shared by most other sub-projects of YouI.
The newest version!
package io.youi.util
case class RangeGroup(calc: () => Int, ranges: Range*) {
def apply[T](values: T*): T = {
assert(values.length == ranges.length, s"Expected ${ranges.length}, got ${values.length}")
val v = calc()
val range = ranges.find(_.contains(v)).getOrElse(throw new RuntimeException(s"Unable to find $v in range group"))
val index = ranges.indexOf(range)
values(index)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy