Kotlin – filter() map examples

In the tutorial, JavaSampleApproach will show you how to filter Kotlin map colletion by examples.

I. Kotlin filter map

Initial data for practicing:

1. filter()

Method signature:

-> Returns a new map containing all key-value pairs matching the given [predicate].

Practice:

2. filterNot()

Method signature:

-> Returns a new map containing all key-value pairs not matching the given [predicate].

Practice:

3. filterTo()

Method signature:

-> Appends all entries matching the given [predicate] into the mutable map given as [destination] parameter.

Practice:

4. filterNotTo()

Method signature:

-> Appends all entries not matching the given [predicate] into the given [destination].

Practice:

5. filterKeys()

Method signature:

-> Returns a map containing all key-value pairs with keys matching the given [predicate].

Practice:

6. filterValues()

Method signature:

-> Returns a map containing all key-value pairs with values matching the given [predicate].

Practice:

II. Full Sourcecode

By JavaSampleApproach | January 23, 2018.


Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*