Is it possible to use enum name without its prefix?
enum class Color { red, blue, green }
data class Shape(val color: Color)
fun main() {
println(Shape(color = red))
}
P.S.
Or maybe it has something like literal types in TypeScript? I don't actually need Enum, the string value would be fine as soon as the Compiler would be able to check the values at compile time, like in TypeScript.
type Color = 'red' | 'blue' | 'green'
class Shape {
constructor(public color: Color) {}
}
console.log(new Shape('red')) // Will be validated at compile time
Color.red?