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

環境
Windows10 Home 64bit
Java 19.0.1
Kotlin 1.7.20-release-201

構文
map変数名.asIterable()
asIterable関数を使ってmutableMapをIterableに変換します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fun main() {
val m = mutableMapOf('t' to 101, 'k' to 202, 'f' to 303)
var res = m.asIterable()
println( res is Set )
}
fun main() { val m = mutableMapOf('t' to 101, 'k' to 202, 'f' to 303) var res = m.asIterable() println( res is Set ) }
fun main() {
            val m = mutableMapOf('t' to 101, 'k' to 202, 'f' to 303)
            var res = m.asIterable()
            println( res is Set ) 
}

実行結果
true

Kotlin

Posted by arkgame