The code below is expected to display the numbers from 1 to 10, but it does not. Why?
val seq = sequence { yieldAll(1..20) }
.filter { it < 11 }
println(seq)
val seq = sequence { yieldAll(1..20) }
.filter { it < 11 }
println(seq)A. You cannot assign a sequence to a variable
B. To produce result, a sequence must have terminal operation. In this case, it needs a .toList()
C. The .filter{ it < 11 } should be .filter{ it > 11 }
D. The yieldAll(1..20) should be yieldAll(1..10)
Answer: Option B
Related Questions on Kotlin Program
A. A new version of Java.
B. A JavaScript framework.
C. A statically-typed programming language for the JVM, Android, and browser.
D. A database management system.
Which platform does Kotlin primarily target?
A. Python Bytecode
B. JavaScript
C. JVM (Java Virtual Machine) Bytecode
D. PHP

Join The Discussion