Hi! I have enum like this: ``` enum class Events {...
# getting-started
n
Hi! I have enum like this:
Copy code
enum class Events {
    "one",
    "two",
    "three"
}
And I need to get List<Map> like this:
Copy code
({name: "one", id: "one"}, {name: "two", id: "two"}, {name: "three", id: "three"})
Is there idiomatic way to do this? No ‘for’ loop.
r
r
Those aren't valid enum values...
👆 4
s
assuming this is what you really want, the code might look closer to this:
Copy code
enum class Events {
    ONE,
    TWO,
    THREE,
}

val mappings = Events.values().map {
    mapOf("name" to it.name.toLowerCase(), "id" to it.name.toLowerCase())
}
n
Yep, I’m sorry about enum syntax. I wrote from memory. @Shawn Thank you! It’s work. I programmed a little in Python and such style are hard for me in Kotlin. I do not know what to do with it.