![List kotlin](https://cdn1.cdnme.se/5447227/9-3/screenshot_8_64e62948e087c31b4a9aa5ed.jpg)
![list kotlin list kotlin](https://media.geeksforgeeks.org/wp-content/uploads/20200329145518/scatterplot1.png)
In this case, we’re using the filterIsInstance() function to return a List of elements of type Integer. Val filterList = countr圜ode.filterIsInstance()ĪssertTrue(ntainsAll(listOf(49,91,81,61))) The filterIsInstance() function can be used to return a List of elements of a specified type: val countr圜ode = listOf("Germany", 49, null, "India", 91, "Japan", 81, "Brazil", null, "Australia", 61) In this example, the filterIndexedTo() function appends the resulting two elements matching the predicate to the mutableList. It then returns a List of elements matching the given predicate: val filterList = countries.filterIndexed )ĪssertTrue(ntainsAll(listOf("United States","Canada","Germany","Australia"))) The predicate of this function uses both the index and the element as arguments.
![list kotlin list kotlin](https://www.topmobileappdevelopmentcompany.com/wp-content/uploads/2020/09/kotlin-768x384.jpg)
We can use the filterIndexed() function to utilize the element position in the filter.
![List kotlin](https://cdn1.cdnme.se/5447227/9-3/screenshot_8_64e62948e087c31b4a9aa5ed.jpg)