If it makes sense semantically to add an operator ...
# getting-started
p
If it makes sense semantically to add an operator extension to the type of
it
, you could do something like this
Copy code
operator fun MyThing.get(attr: String): String? = if (hasAttribute(attr)) getAttribute(attr) else null
...
val animName = it["name"] ?: it["id"] ?: "animation..."
👍 3