How do I declare a variable of enum type in Kotlin? -
according documentation created enum class
enum class bitcount public constructor(val value : int) { x32(32), x64(64) }
then i'm trying declare variable in function
val bitcount : bitcount = bitcount(32)
but there compilation error
how declare variable of bitcount type , initialize int
?
error:(18, 29) kotlin: enum types cannot instantiated
enum instances declared inside enum class declaration.
if want create new bitcount add shown below:
enum class bitcount public constructor(val value : int) { x16(16), x32(32), x64(64) }
and use everywhere bitcount.x16
.
Comments
Post a Comment