Scala match/compare enumerations

Posted by williamstw on Stack Overflow See other posts from Stack Overflow or by williamstw
Published on 2010-05-05T14:42:17Z Indexed on 2010/05/05 15:48 UTC
Read the original article Hit count: 216

Filed under:

I have an enumeration that I want to use in pattern matches in an actor. I'm not getting what i'd expect and, now, I'm suspecting I'm missing something simple.

My enumeration,

object Ops extends Enumeration {
  val Create = Value("create")
  val Delete = Value("delete")
}

Then, I create an Ops from a String:

val op = Ops.valueOf("create")

Inside my match, I have:

case (Ops.Create, ...)

But Ops.Create doesn't seem to equal ops.valueOf("create")

The former is just an atom 'create' and the later is Some(create)

Hopefully, this is enough info for someone to tell me what I'm missing...

Thanks

© Stack Overflow or respective owner

Related posts about scala