Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Filter functions
//filter
println(languagesList.filter { it.name.contains('k') })
//filterNot(), filterNotNull()
println(languagesList.filterNot { it.name.contains('k') })
println(languagesList.filterNotNull())
//filterTo(), filterNotTo()
var listToFilterInto = mutableListOf<Language>()
languagesList.filterTo(listToFilterInto) { it.town.contains('o') }
languagesList.filterNotTo(listToFilterInto) { it.town.contains('o') }
languagesList.filterNotNullTo(listToFilterInto)
//filterIndexed()
println(languagesList.filterIndexed { index, _ -> index % 3 == 0})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment