title: Scala - can unapply return varargs?
body: <p>Object <code>L1</code> below works.  I can "create" an <code>L1</code> by passing in varargs, which is nice, but I would like to be able to assign to an <code>L1</code> using the same syntax. Unfortunately, the way I've done it here requires the uglier syntax of nesting an <code>Array</code> inside the <code>L1</code>.</p>
  
  <pre><code>object L1 {
      def apply(stuff: String*) = stuff.mkString(",")
      def unapply(s: String) = Some(s.split(","))
  }
  val x1 = L1("1", "2", "3")
  val L1(Array(a, b, c)) = x1
  println("a=%s, b=%s, c=%s".format(a,b,c))
  </code></pre>
  
  <p>I attempted accomplish this in what seems like an obvious way, as in <code>L2</code> below:</p>
  
  <pre><code>object L2 {
      def apply(stuff: String*) = stuff.mkString(",")
      def unapply(s: String) = Some(s.split(","):_*)
  }
  val x2 = L2("4", "5", "6")
  val L2(d,e,f) = x2
  println("d=%s, e=%s, f=%s".format(d,e,f))
  </code></pre>
  
  <p>But this give the error:</p>
  
  <pre><code>error: no `: _*' annotation allowed here 
  (such annotations are only allowed in arguments to *-parameters)`.
  </code></pre>
  
  <p>Is it possible for <code>unapply</code> to use varargs in this way?</p>