Skip to content

Instantly share code, notes, and snippets.

@bigtoast
Created January 20, 2011 00:57
Show Gist options
  • Save bigtoast/787211 to your computer and use it in GitHub Desktop.
Save bigtoast/787211 to your computer and use it in GitHub Desktop.
Notes on Scala Effective Enum patterns.
sealed abstract class MyEnum
object MyEnum {
def apply(str :String) :MyEnum { // do str conversions }
object Val1 extends MyEnum
object Val2 extends MyEnum
}
we need the abstract class for matching the enum type. It can't be a trait because the compiler gets confused with the apply method in the object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment