Complete the code to transform each number by doubling it using the map operator.
val numbers = flowOf(1, 2, 3) val doubled = numbers.[1] { it * 2 }
The map operator applies a transformation to each element in the flow.
Complete the code to keep only even numbers using the filter operator.
val numbers = flowOf(1, 2, 3, 4) val evens = numbers.[1] { it % 2 == 0 }
The filter operator keeps only elements that satisfy the condition.
Fix the error in the code to emit both original and doubled values using transform.
val numbers = flowOf(1, 2) val result = numbers.[1] { emit(it); emit(it * 2) }
The transform operator allows emitting multiple values per input.
Fill both blanks to create a flow of squares of odd numbers.
val numbers = flowOf(1, 2, 3, 4, 5) val squaresOfOdds = numbers.[1] { it % 2 != 0 }.[2] { it * it }
First, filter keeps odd numbers, then map squares them.
Fill all three blanks to emit strings for numbers greater than 2, doubled and converted to string.
val numbers = flowOf(1, 2, 3, 4) val result = numbers.[1] { it [2] 2 }.[3] { (it * 2).toString() }
Filter numbers greater than 2, then map to double and convert to string.
