summaryrefslogtreecommitdiff
path: root/core/src/main/scala/mill/define/Cross.scala
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/scala/mill/define/Cross.scala')
-rw-r--r--core/src/main/scala/mill/define/Cross.scala16
1 files changed, 12 insertions, 4 deletions
diff --git a/core/src/main/scala/mill/define/Cross.scala b/core/src/main/scala/mill/define/Cross.scala
index ac1ee966..85341d12 100644
--- a/core/src/main/scala/mill/define/Cross.scala
+++ b/core/src/main/scala/mill/define/Cross.scala
@@ -9,10 +9,18 @@ case class Cross[+T](items: List[(List[Any], T)]){
def map[V](f: T => V): Cross[V] = new Cross(items.map{case (l, v) => (l, f(v))})
def withFilter(f: T => Boolean): Cross[T] = new Cross(items.filter(t => f(t._2)))
- def applyOpt(input: List[Any]): Option[T] = items.find(_._1 == input).map(_._2)
- def apply(input: List[Any]): T = applyOpt(input).getOrElse(
- throw new Exception("Unknown set of cross values: " + input + " not in known values\n" + items.map(_._1).mkString("\n"))
- )
+ def applyOpt(input: Any*): Option[T] = {
+ val inputList = input.toList
+ items.find(_._1 == inputList).map(_._2)
+ }
+ def apply(input: Any*): T = {
+ applyOpt(input:_*).getOrElse(
+ throw new Exception(
+ "Unknown set of cross values: " + input +
+ " not in known values\n" + items.map(_._1).mkString("\n")
+ )
+ )
+ }
}
object Cross{
def apply[T](t: T*) = new Cross(t.map(i => List(i) -> i).toList)