does c#'s <pattern matching> they intrigue the kot...
# language-evolution
h
does c#'s pattern matching they intrigue the kotlin team at all?
e
Seems very similar to Kotlin. Is there anything specific you were thinking of?
h
take a look at how it can be used in switch expressions or by comparing nested values as well as "not", "and", "or", "with", etc
e
I'm pretty sure that's all covered by Kotlin's smart casting and
when
. At first glance it didn't look like there was anything that couldn't be done in Kotlin.
h
here's an example of what you could do in kotlin with all the pattern matching you have in c#:
Copy code
val Number.normalized
    get(): Int = when (toInt()) {
        > 0 -> 1
        < 0 -> -1
        else -> 0
    }
e
Many of the practical use-cases of C#’s pattern matching are already covered by Kotlin’s
when
, but not all of them. Please, add your feedback on the use-cases you encounter in Kotlin code to https://youtrack.jetbrains.com/issue/KT-186