Wzór dopasowujący „przypadek zero” dla Vector

Po przeczytaniu tegosłupek jak używać dopasowania wzorcówVector (lub dowolna kolekcja, która implementujeSeq), Przetestowałem dopasowanie wzoru w tej kolekcji.

scala> x // Vector
res38: scala.collection.immutable.Vector[Int] = Vector(1, 2, 3)

scala> x match {
     |    case y +: ys => println("y: " + "ys: " + ys)
     |    case Nil => println("empty vector")
     | }
<console>:12: error: pattern type is incompatible with expected type;
 found   : scala.collection.immutable.Nil.type
 required: scala.collection.immutable.Vector[Int]
Note: if you intended to match against the class, try `case _: <none>`
                 case Nil => println("empty vector")
                      ^

Otodhgodpowiedź, która wyjaśnia+::

object +: {
  def unapply[T](s: Seq[T]) =
    s.headOption.map(head => (head, s.tail))
}

REPL pokazuje mi to

scala> Vector[Int]() == Nil
res37: Boolean = true

... więc dlaczego nie mogę tego użyćcase Nil oświadczenie dlaVector?

questionAnswers(1)

yourAnswerToTheQuestion