mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
When by String constants:
Generate TABLESWITCH/LOOKUPSWITCH bytecode operation for when operator by String constants
This commit is contained in:
committed by
Evgeny Gerashchenko
parent
5a1c995b5c
commit
d4cb822ee8
@@ -0,0 +1,16 @@
|
||||
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
|
||||
Reference in New Issue
Block a user