List Filtering and Mapping
Filter and transform elements in a list using the filter and map functions to create a new list with specific criteria.
Filter and transform elements in a list using the filter
and map
functions to create a new list with specific criteria.
val numbers = listOf(1, 2, 3, 4, 5, 6)
val evenSquares = numbers
.filter { it % 2 == 0 }
.map { it * it }