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

環境
java 19.0.1
kotlin 1.7.20-release-201

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

使用例

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)
var t = m.asSequence()
println( t is Set<*> ) // false
println( t is Map<*,*> ) // false
println( t is Sequence<*> ) // true
}
fun main() { val m = mutableMapOf('s' to 11, 't' to 22, 'u' to 33) var t = m.asSequence() println( t is Set<*> ) // false println( t is Map<*,*> ) // false println( t is Sequence<*> ) // true }
fun main() {


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

    var t = m.asSequence()

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

}

実行結果
false
false
true

IT

Posted by arkgame