<@U0SBUNBC6> You could use a when statement, I don...
# announcements
d
@somoni You could use a when statement, I don’t know that it’s actually O(1) but it’s definitely no worse than an if/else chain. ie.
Copy code
val obj: Any = "asdf"
    when(obj) {
        is Int -> println("Int!")
        is Double -> println("Double!")
        is String -> { println("String!") } // you can add braces if you have a longer statement
    }
g
dalexander: This linear time, not constant time. I believe that with a better pattern matching mechanism and access into the object record's header it can be sped up, but that might be waiting on project-valhala.