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

環境
java 19.0.1
kotlin 1.7.20

構文
map名.asSequence()
mutableMapをSequenceに変換するには、「asSequence」関数を使用します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fun main() {
val m = mutableMapOf('a' to 11, 'b' to 22, 'c' to 53)
var t = m.asSequence()
println( t is Set<*> )
println( t is Map<*,*> )
println( t is Sequence<*> )
}
fun main() { val m = mutableMapOf('a' to 11, 'b' to 22, 'c' to 53) var t = m.asSequence() println( t is Set<*> ) println( t is Map<*,*> ) println( t is Sequence<*> ) }
fun main() {


    val m = mutableMapOf('a' to 11, 'b' to 22, 'c' to 53)

    var t = m.asSequence()

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

    
}

実行結果
false
false
true

IT

Posted by arkgame