mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 00:21:29 +00:00
And String.length as well. This is done for JVM interoperability: java.lang.CharSequence is an open class and has a function 'length()' which should be implemented in subclasses somehow. A minor unexpected effect of this is that String.length() is now a compile-time constant (it wasn't such as a property because properties are not supported in compile-time constant evaluation) #KT-3571 Fixed
39 lines
572 B
Kotlin
39 lines
572 B
Kotlin
package test
|
|
|
|
enum class MyEnum {
|
|
A
|
|
}
|
|
|
|
// val prop1: \"2\"
|
|
val prop1 = "${1 + 1}"
|
|
|
|
// val prop2: null
|
|
val prop2 = "myEnum=${MyEnum.A}"
|
|
|
|
// val prop3: \"1\"
|
|
val prop3 = "${1}"
|
|
|
|
// val prop4: \"null\"
|
|
val prop4 = "${null}"
|
|
|
|
// val prop5: \"1.0\"
|
|
val prop5 = "${1.toFloat()}"
|
|
|
|
// val prop6: \"1.0\"
|
|
val prop6 = "${1.0}"
|
|
|
|
// val prop7: null
|
|
val prop7 = "${javaClass<Int>()}"
|
|
|
|
// val prop8: \"a1.0\"
|
|
val prop8 = "a${1.toDouble()}"
|
|
|
|
// val prop9: \"ab\"
|
|
val prop9 = "a" + "b"
|
|
|
|
// val prop10: \"abb\"
|
|
val prop10 = prop9 + "b"
|
|
|
|
// val prop11: 6
|
|
val prop11 = "kotlin".length()
|