5/3/2023 0 Comments Kotlin any exampleLet's learn about a way to combine two collections, and create a new one from them – it's time to zip!Īssume we have two collections, where the elements at each index are somehow related. So far, we have always looked at a single collection, and what we can do with it. If you are doing an operation on a list, which in turn generates a collection for each one of the input elements, consider if flatMap can help you simplify your code! As desired, we end up with a plain list of elements – the list of characters from the names of the original collection. Next, that collection of collections gets flattened. In the example above, the function that we provide creates a list for each element in our input collection, containing the letters of the original string. Enter fullscreen mode Exit fullscreen mode
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |