pawel.barszcz
05/26/2017, 3:12 PMdata class Color(
val redAsText: String,
val greenAsText: String,
val blueAsText: String
) {
init {
val red = try {
redAsText.toInt()
} catch (t: Throwable) {
throw IllegalArgumentException("Red pigment is invalid.")
}
if (red < 0 || red > 255) throw IllegalArgumentException("Red pigment is invalid.")
// etc.
}
}
fun x() {
val (r, g, b) = Color("1", "2", "3")
// r is String, not Int
}