Jim*_*een 4 java open-source source-code-protection kotlin kotlin-android-extensions
在kotlin源代码中,我无法理解如何实现String.kt的长度,如下:
package kotlin
public class String : Comparable<String>, CharSequence {
companion object {}
/**
* Returns a string obtained by concatenating this string with the string representation of the given [other] object.
*/
public operator fun plus(other: Any?): String
public override val length: Int
public override fun get(index: Int): Char
public override fun subSequence(startIndex: Int, endIndex: Int): CharSequence
public override fun compareTo(other: String): Int}
Run Code Online (Sandbox Code Playgroud)
var len:Int = "abc".length; // len = 3 where to run the length??
在哪里实现长度函数?
Kis*_*kae 10
字符串函数是Kotlin认为Intrinsic
函数的例子.它们是基于它们运行的平台定义的,您将无法在源代码中找到它们的实现.
对于JVM,它们将直接映射到相应的本机java.lang.String
方法.这可确保不存在运行时开销,并利用java标准库中的优化.
归档时间: |
|
查看次数: |
340 次 |
最近记录: |