Hello, guys. Can you please help me to translate p...
# announcements
k
Hello, guys. Can you please help me to translate piece of code into pure Kotlin? map here is mapping from String to MyClass. I have an extension property MyClass.finished; I need to create new instance of object if it is not in
map
, or it is finished. If it is not finished and in
map
, just return that value How to do it in Kotlin-way?
Copy code
if (id in map) {
            val existing = map[id]!!
            if (!existing.finished)
                return existing
}

val timer = map[id] ?: MyClass.create()
// everything not so important here...