I’m wondering why unapplySeq was added, when unapply seems good enough?
Pattern sequence with “unapplySeq(…) : Option[Seq[…]]”:
case b() => …
case b(_) => …
case b(_,_) => …
case b(_,_,_*) => …
An equivalent pattern with “unapply(…) : Option[Seq[…]]”:
case b( Nil ) => …
case b( _ +: Nil ) => …
case b( _ +: _ +: Nil ) => …
case b( _ +: _ +: _ ) => …
The pattern sequence could be just a syntactic sugar for the latter, but Scala went further to add unapplySeq. Is there anything that can’t be achieved with unapply alone?
What was the thinking behind pattern sequence feature in Scala?