This small code gives error: unresolved reference: make :
sealed class Color () {
object Red : Color()
object Blue : Color()
override fun toString(): String =
when (this) {
is Red -> "Red"
is Blue -> "Blue"
else -> "Error"
}
fun make(name: String): Color {
return when (name) {
"Red" -> Red
"Blue" -> Blue
else -> throw Exception ("Error unkown color '$name'")
}
}
}
fun main(args: Array<String>) {
val color = Color.make("Red")
println (color.toString())
}
I tried val color = make("Red") and got the same error. Why ? What I have to do to fix that ?