I’m getting an warning which I don’t know how to stifle. Can someone help me understand exactly what the warning is telling me and how to fix it?
Warning:(159, 67) match may not be exhaustive.
It would fail on the following inputs: (((_ : Int), (_ : Int)), (_, (_ : Int), _)), (((_ : Int), (_ : Int)), (_, _, (_ : Int))), (((_ : Int), (_ : Int)), (_, _, _)), (((_ : Int), (_ : Int)), _), (((_ : Int), _), (_, (_ : Int), (_ : Int))), (((_ : Int), _), (_, (_ : Int), _)), (((_ : Int), _), (_, _, (_ : Int))), (((_ : Int), _), (_, _, _)), (((_ : Int), _), _), ((_, (_ : Int)), (_, (_ : Int), (_ : Int))), ((_, (_ : Int)), (_, (_ : Int), _)), ((_, (_ : Int)), (_, _, (_ : Int))), ((_, (_ : Int)), (_, _, _)), ((_, (_ : Int)), _), ((_, _), (_, (_ : Int), (_ : Int))), ((_, _), (_, (_ : Int), _)), ((_, _), (_, _, (_ : Int))), ((_, _), (_, _, _)), ((_, _), _), (_, (_, (_ : Int), (_ : Int))), (_, (_, (_ : Int), _)), (_, (_, _, (_ : Int))), (_, (_, _, _)), (_, _)
val (minX:Int, minY:Int) = stationPositions.fold((maxX,maxY)) {
Here is the code. The error occurs on the line which sets the value of minX and minY, but not on the code that sets maxX and maxY. In my actual program the value of stationPositions is a much larger array than shown here with just 3 entries.
object TestingMetroMap {
def main(argv:Array[String]):Unit = {
val stationPositions:Array[(String,Int,Int)] = Array(
// station-name, x-position, y-position, useful for drawing a metro map
("Abbesses", 308, 536 ),
("Alexandre Dumas", 472, 386 ),
("Alma Marceau", 193, 404 ))
val (maxX: Int, maxY: Int) = stationPositions.foldLeft((0, 0)) {
case ((maxX, maxY), (_, x, y)) => (math.max(x, maxX), math.max(y, maxY))
}
val (minX:Int, minY:Int) = stationPositions.fold((maxX,maxY)) {
case ((minX:Int, minY:Int), (_, x:Int, y:Int)) => (math.min(x,minX), math.min(y,minY))
}
println(List(minX, minY, maxX, maxY))
}
}