-
-
Save mrerrormessage/ebf66e04cea2533648ed to your computer and use it in GitHub Desktop.
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 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 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