![]() ![]() This will insert the values “2” and “4” into the list “target”. This can be useful for processing several input collections into the same output collection, for example: val target = mutableList() Some of these operations also have an additional version – suffixed with the word “To” – that outputs into a provided collection instead of producing a new one. ![]() This will return the single value “9” – 3². For example: val oddSquared = listOf(1, 2, 3, 4, 5) ![]() Out of these operations, there are are several that work exactly the same – filter(), map(), flatMap(), distinct() and sorted() – and some that work the same only with different names – limit() is now take, and skip() is now drop(). These are not intermediate operations though – except in the case of the Sequence class – as they result in fully populated collections from processing the input collection. Almost all intermediate operations from the Java 8 Streams API have equivalents in Kotlin. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |