Answer the question
In order to leave comments, you need to log in
Why does an exception occur when assigning a tuple?
I execute the code in the interpreter:
scala> val coords = Vector((0,0))
coords: scala.collection.immutable.Vector[(Int, Int)] = Vector((0,0))
scala> val (x, y) = coords(0)
java.lang.AssertionError: assertion failed: List(value _1$mcI$sp, value _1$mcI$sp, value _1$mcI$sp)
at scala.reflect.internal.Symbols$Symbol.suchThat(Symbols.scala:1916)
scala> val z = coords(0)
z: (Int, Int) = (0,0)
scala> val (x, y) = z
x: Int = 0
y: Int = 0
val (x, y) = coords(0)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question