Created
February 26, 2009 14:25
-
-
Save DRMacIver/70874 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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