Implementing class for pattern matching

Posted by Jeriho on Stack Overflow See other posts from Stack Overflow or by Jeriho
Published on 2010-05-24T20:56:17Z Indexed on 2010/05/24 21:01 UTC
Read the original article Hit count: 195

Filed under:
|

For example,

val list = List(1,2,3)
list match{
  case a:::b => 
  case _ => 
}

you can match head and tail of a List using :::' or tokens of ParseResult using~'. What should I do to create class that can be matched like preceding classes?

© Stack Overflow or respective owner

Related posts about scala

Related posts about pattern-matching