kotlin mutableMapをIterableに変換するサンプル

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

構文
map名.asIterable()
mutableMapをIterableに変換するには、「asIterable」を利用します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fun main() {
val m = mutableMapOf('s' to 21, 't' to 32, 's' to 43)
var t = m.asIterable()
println( t is Set )
println( t is Map<*,*> )
}
fun main() { val m = mutableMapOf('s' to 21, 't' to 32, 's' to 43) var t = m.asIterable() println( t is Set ) println( t is Map<*,*> ) }
fun main() {


    val m = mutableMapOf('s' to 21, 't' to 32, 's' to 43)

    var t = m.asIterable()

    println( t is Set )
    println( t is Map<*,*> ) 

}

実行結果
true
false

Kotlin

Posted by arkgame