``` data class Color( val redAsText: Strin...
# announcements
p
Copy code
data 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
}