This page is no longer maintained — Please continue to the home page at

Re: Re: the ultimate scala cheat sheet

No replies
Joined: 2009-08-14,
User offline. Last seen 2 years 3 weeks ago.
As an astute observer points out it _does_ in fact throw a match error.

I had forgotten that the REPL is what doesn't even bother evaluating the match if there are no variables returned.

Sorry for the misinformation.  It's just a full-blown regular match (but the REPL is too clever).


On Tue, Dec 27, 2011 at 8:37 PM, Martin McNulty <martin [at] mcnulty [dot] me [dot] uk> wrote:
2011/12/26 Rex Kerr <ichoran [at] gmail [dot] com>
However, when there are no variables to match, Scala accepts the match syntax _but doesn't check the values_, so

  val (1,2) = (1,3)

and even

  val 1 = 2

silently do nothing instead of throwing a MatchError.  

I was curious so I tried it but, at least in, it seems to throw a MatchError.  Am I missing something?

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland