maionavigator.blogg.se

Kotlin collection functions
Kotlin collection functions







It is also worth noting that in the above code we called the filter function first and then the map function. "Grape")įor-in loops can be used not only to iterate over intervals, but also over collections: fun main (a) Īs you can see, both the filter and map functions are used and the fruit word is limited to five letters by the Lambda representation. This is a bit more cumbersome, Kotlin writes: val list = listOf( "Apple". Kotlin writes ArrayList in Java thinking: val list = ArrayListString() The main implementation classes of List are ArrayList and LinkedList, the main implementation class of Set is HashSet, and the main implementation class of Map is HashMap. List, Set, and Map are all interfaces in Java. The functional API for collections is an excellent example of learning Lambda programming.Ĭollections have traditionally been lists and sets, but more broadly key-value data structures such as maps can also be included.

kotlin collection functions

Small knowledge, big challenge! This article is participating in the creation activity of "Essential Tips for Programmers".









Kotlin collection functions