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
}
1
  • 2
    possible dublicate. See Ben James answer. Commented Aug 22, 2011 at 14:42

1 Answer 1

8

bracket value2 with backticks:

case `value2` => true
Sign up to request clarification or add additional context in comments.

1 Comment

thanks, looks like trick. I think this behavior can be removed in future versions....

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.