Forked from mrerrormessage/ActuallyCompiles.scala
Last active
August 29, 2015 14:09
-
-
Save TheBizzle/86726b76b8a91ae6918a 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 InputBoxType[T](val name:String) | |
| case object Num extends InputBoxType[Double]("Number") | |
| case object Str extends InputBoxType[String]("String") | |
| case object StrReporter extends InputBoxType[String]("String (reporter)") | |
| case object StrCommand extends InputBoxType[String]("String (commands)") | |
| case object Col extends InputBoxType[Int]("Color") | |
| case class InputBox[T](left: Int = 0, top: Int = 0, right: Int = 0, bottom: Int = 0, varName: String, value: T, multiline: Boolean = false, boxtype: InputBoxType[T]){ | |
| def say: String = boxtype match { | |
| case c: Col.type => "hello" | |
| case _ => "goodbye" | |
| } | |
| } | |
| val ib = InputBox(0, 0, 0, 0, "apples", 9001, false, Col) | |
| val ib2 = InputBox(0, 0, 0, 0, "apples", 9001.0, false, Num) |
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 InputBoxType[T](val name:String) | |
| case object Num extends InputBoxType[Double]("Number") | |
| case object Str extends InputBoxType[String]("String") | |
| case object StrReporter extends InputBoxType[String]("String (reporter)") | |
| case object StrCommand extends InputBoxType[String]("String (commands)") | |
| case object Col extends InputBoxType[Int]("Color") | |
| case class InputBox[T](left: Int = 0, top: Int = 0, right: Int = 0, bottom: Int = 0, varName: String, value: T, multiline: Boolean = false, boxtype: InputBoxType[T]){ | |
| def say: String = boxtype match { | |
| case Col => "hello" | |
| case _ => "goodbye" | |
| } | |
| } | |
| val ib = InputBox(0, 0, 0, 0, "apples", 9001, false, Col) | |
| val ib2 = InputBox(0, 0, 0, 0, "apples", 9001.0, false, Num) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment