3 ms·
In Kotlin data class Person (val name: String, val age: Int) val c1 = listOf(Person("A", 5), Person("B", 6), Person("C", 4)) val c2 = c1.filter{ it
by sorokod 7y ago
In Kotlin
data class Person (val name: String, val age: Int)
val c1 = listOf(Person("A", 5), Person("B", 6), Person("C", 4))
val c2 = c1.filter{ it.age > 4 }.map{ it.copy(age = it.age*2) }
- dxxvi 7y agoKotlin and Java don't have a powerful pattern matching like Scala. Maybe that's why they don't have `collect` for filter + map. However I'm learning kotlin now because my employer doesn't allow me to use Scala