Skip to content

Instantly share code, notes, and snippets.

@lopex
Created December 5, 2010 19:11
Show Gist options
  • Save lopex/729357 to your computer and use it in GitHub Desktop.
Save lopex/729357 to your computer and use it in GitHub Desktop.
class Dupa(val a: Int, val b: Int) {
override def toString = "Dupa" + a + ": " + b
}
case object Dupa {
def apply(a: Int, b: Int) = new Dupa(a, b)
def unapply(s: String) = s.split(":") match {
case Array(a, b) => Some(Dupa(a.toInt, b.toInt))
case _ => None
}
def unapply(s: AnyRef) = s match {
case d:Dupa => Some((d.a, d.b))
case _ => None
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment