Skip to content

Instantly share code, notes, and snippets.

@DRMacIver
Created February 26, 2009 14:25
Show Gist options
  • Select an option

  • Save DRMacIver/70874 to your computer and use it in GitHub Desktop.

Select an option

Save DRMacIver/70874 to your computer and use it in GitHub Desktop.
abstract class MyList{
def toList : List[Int] = this match {
case Nope => Nil
case Cons(x, y) => x :: y.toList
}
override def equals(that : Any) = that match {
case (that : MyList) => this.toList == that.toList;
case _ => false;
}
}
case class Cons(x : Int, y : MyList) extends MyList;
case object Nope extends MyList;
object Test{
def main(args : Array[String]){
println(Nope.toList)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment