Do I need a nested Sealed class?

380 views Asked by At

Need help with my example sealed class

sealed class Color
 object Red: Color()
 object Green: Color()
 object Blue: Color()

 class NewColor(
    var flag: Boolean = false,
    var id: String = "" or Int = -1 <-----I want id to be either an Int or String
): Color()

I'd like to be able to assign an Int or String to id. Do I need another sealed class?

So I can use it like

...
var result = NewColor(
        id = "Purple" or id = R.color.purple
    )
0

There are 0 answers