2

Possible Duplicates:
Why does pattern matching in Scala not work with variables?
Pattern match for variable in scope (Scala)

For example I have code

def equals(value1:String, value2:String) = value1 match {
 case value2 => true
 case _ => false
}

I found workaround, but I do not really like syntax

def equals(value1:String, value2:String) = value1 match {
 case v if v == value2 => true
 case _ => false
}
Community
  • 1
  • 1
yura
  • 14,489
  • 21
  • 77
  • 126
  • 2
    possible [dublicate](http://stackoverflow.com/questions/7078022/why-does-pattern-matching-in-scala-not-work-with-variables). See Ben James answer. – om-nom-nom Aug 22 '11 at 14:42

1 Answers1

8

bracket value2 with backticks:

case `value2` => true
Didier Dupont
  • 29,398
  • 7
  • 71
  • 90
  • thanks, looks like trick. I think this behavior can be removed in future versions.... – yura Aug 22 '11 at 17:06