Is destructuring input parameters available in Scala?

Is there a way to destructure input parameters of a function in Scala (akin to Clojure)?

So, instead of

scala> def f(p: (Int, Int)) = p._1
f: (p: (Int, Int))Int

I'd like to have this (it doesn't work):

scala> def f((p1, p2): (Int, Int)) = p1


I guess in scala you would use pattern matching to achieve the same, e.g. like this:

val f: (Int, Int) => Int = { case (p1, p2) => p1 }

Or, equivalently:

def f(p: (Int, Int)) = p match { case(p1, p2) => p1 }

If the types can be inferred, the (Int, Int) => Int can be dropped:

List((1, 2), (3, 4)) map { case (p1, p2) => p1 }

Need Your Help

Cannot run Errai Dev Mode with JBoss AS or Wildfly

java gwt jboss wildfly errai

I'm trying to use Errai 3 new features which is JBoss AS integration, however I am getting this error:

Rails Mailer “Net::OpenTimeout: execution expired” Exception on production server only

ruby-on-rails smtp actionmailer exception-notification

I am using Ruby MRI 2.0.0 and Rails 3.2.12 on a Ubuntu 12.04 TLS VPS and attempting to setup email notifications in my app. It was working fine a few days ago, but not anymore. My web host is OVH.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.