Kotlin methods – any(), none(), all(), contains()

In the tutorial, JavaSampleApproach will show you how to work with some Kotlin methods: any(), all(), none(), contains().

I. Kotlin methods – any(), none(), all(), contains()

1. any() vs none() methods

Kotlin has 2 signatures for any() method:

none() method is the opposite of any() method. none() method has 2 signatures:

Practice:

2. all() method

all() method is used to check if all elements match the given [predicate]. Method signature:

Practice:

3. contains() method

contains() method is used to check a given element having in the list or not.

Practice:

II. Full Sourcecode

By JavaSampleApproach | January 5, 2018.

Related Posts


Got Something To Say:

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

*