kotlin mutableMapのkeyのみを全て取得するサンプル

環境
Windows11 pro 64bit
java 19.0.1
kotlin 1.7.20-release-201

構文
map名.keys
「keys」を使ってkeyのみを全て取得します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fun main() {
val m = mutableMapOf('s' to 11, 't' to 22, 'u' to 33)
println( m.keys )
}
fun main() { val m = mutableMapOf('s' to 11, 't' to 22, 'u' to 33) println( m.keys ) }
fun main() {

    val m = mutableMapOf('s' to 11, 't' to 22, 'u' to 33)

    println( m.keys )

}

実行結果
[s, t, u]

Kotlin

Posted by arkgame