kotlin mutableMapのkeyと値をsetで全て取得するサンプル

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

構文
map名.entries
keyと値をsetで全て取得するには、「entries」を利用します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fun main() {
val m = mutableMapOf('s' to 21, 'b' to 32, 'c' to 53)
println( m.entries )
}
fun main() { val m = mutableMapOf('s' to 21, 'b' to 32, 'c' to 53) println( m.entries ) }
fun main() {

    val m = mutableMapOf('s' to 21, 'b' to 32, 'c' to 53)

    println( m.entries ) 

}

実行結果
[s=21, b=32, c=53]

Kotlin

Posted by arkgame