code所在位置是kotlin.code,其相關用法介紹如下。

用法:

<code class="kotlin">inline val Char.code: Intcode>

返回此 Char 的代碼。

一個 Char 的代碼是構造它的值,以及與這個 Char 對應的 UTF-16 代碼單元。

例子:

<code class="kotlin">import java.util.*
import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val string = "0Azβ"
println(string.map { it.code }) // [48, 65, 122, 946]
//sampleEnd
}code>

輸出:

[48, 65, 122, 946]