Unpacking tuple directly into class in scala
<p>Scala gives the ability to unpack a tuple into multiple local variables when performing various operations, for example if I have some data</p>

<pre><code>val infos = Array(("Matt", "Awesome"), ("Matt's Brother", "Just OK"))
</code></pre>

<p>then instead of doing something ugly like</p>

<pre><code>infos.map{ person_info =&gt; person_info._1 + " is " + person_info._2 }
</code></pre>

<p>I can choose the much more elegant</p>

<pre><code>infos.map{ case (person, status) =&gt; person + " is " + status }
</code></pre>

<p>One thing I've often wondered about is how to directly unpack the tuple into, say, the arguments to be used in a class constructor. I'm imagining something like this:</p>

<pre><code>case class PersonInfo(person: String, status: String)
infos.map{ case (p: PersonInfo) =&gt; p.person + " is " + p.status }
</code></pre>

<p>or even better if <code>PersonInfo</code> has methods:</p>

<pre><code>infos.map{ case (p: PersonInfo) =&gt; p.verboseStatus() }
</code></pre>

<p>But of course this doesn't work. Apologies if this has already been asked -- I haven't been able to find a direct answer -- is there a way to do this?</p>