mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Generate TABLESWITCH/LOOKUPSWITCH bytecode operation for when operator by String constants
17 lines
303 B
Kotlin
17 lines
303 B
Kotlin
import kotlin.test.assertEquals
|
|
|
|
fun foo(x : String) : String {
|
|
assert("abz]".hashCode() == "aby|".hashCode())
|
|
|
|
when (x) {
|
|
"abz]" -> return "abz"
|
|
"ghi" -> return "ghi"
|
|
"aby|" -> return "aby"
|
|
"abz]" -> return "fail"
|
|
}
|
|
|
|
return "other"
|
|
}
|
|
|
|
// 1 LOOKUPSWITCH
|