Complete the code to zip two flows and collect their combined values.
val flow1 = flowOf(1, 2, 3) val flow2 = flowOf("A", "B", "C") flow1.[1](flow2) { a, b -> "$a$b" } .collect { println(it) }
The zip function combines two flows by pairing their elements one by one.
Complete the code to combine two flows and collect their latest values.
val flow1 = flowOf(1, 2, 3) val flow2 = flowOf("X", "Y", "Z") flow1.[1](flow2) { a, b -> "$a$b" } .collect { println(it) }
The combine function merges two flows by combining their latest emitted values.
Fix the error in the code to correctly zip two flows and print combined results.
val numbers = flowOf(1, 2, 3) val letters = flowOf("a", "b", "c") numbers.[1](letters) { num, letter -> "$num$letter" } .collect { println(it) }
Using zip pairs elements from both flows correctly for combined output.
Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.
val words = listOf("apple", "bat", "carrot", "dog") val lengths = words.associateWith { [1] } .filter { it.value [2] 3 }
it.length gets the length of each word, and > filters words longer than 3.
Fill all three blanks to create a map of uppercase words to their lengths for words longer than 4 characters.
val words = listOf("pear", "plum", "banana", "kiwi") val result = words.filter { it.length [1] 4 } .associateBy( keySelector = { it.[2]() }, valueTransform = { it.[3] } )
Filter words longer than 4, use uppercase() for keys, and length for values.