Created
September 20, 2012 00:47
-
-
Save stephenLee/3753293 to your computer and use it in GitHub Desktop.
Scala case class
This file contains 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 Expr | |
case class Var(name: String) extends Expr | |
case class Number(num: Double) extends Expr | |
case class UnOp(operator: String, arg: Expr) extends Expr | |
case class BinOp(operator: String, left: Expr, right: Expr) extends Expr | |
val v = Var("x") | |
val op = BinOp("+", Number(1), v) | |
v.name | |
op.left | |
op.right == Var("x") | |
op.copy(operator = "-") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment