When we call foo + 1 we are given a new list back that we ignore. So this now explains why, in our original example, we were left looking at an empty list. Here’s the important thing to remember: it doesn’t modify the original list. adds all elements from the original list to it.Note the signature of this function: it has operator in the signature and is called plus - this is why it is invoked when you call foo + 1. Here are the examples: a.* Returns a list containing all elements of the original collection and then the given. Val names = listOf("joel", "ed", "chris", "maurice") The following examples use these lists: val a = listOf(10, 20, 30, 40, 10) GroupBy, groupByTo, groupingBy, partition StatisticsĪverage, count, max, maxBy, maxWith, min, minBy, minWith, sum, sumBy Information about the collectionĪll, any, contains, containsAll, none, forEach, forEachIndexed, isEmpty, isNotEmpty, onEach Examples Filtering methodsīinarySearch, distinct, distinctBy, drop, dropWhile, dropLast, dropLastWhile, elementAt, elementAtOrElse, elementAtOrNull, filter, filterIndexed, filterIsInstance, find, findLast, first, firstOrNull, get, getOrElse, indexOf, indexOfFirst, indexOfLast, intersect, last, lastIndexOf, lastOrNull, orEmpty, single, singleOrNull, take, takeWhile, takeLast, takeLastWhile, union TransformersĪssociate, flatten, flatMap, intersect, map, mapNotNull, mapIndexed, mapIndexedNotNull, reversed, slice, sorted, sortedByDescending, sortedWith, union, unzip, zip Aggregatorsįold, foldIndexed, foldRight, foldRightIndexed, reduce, reduceIndexed, reduceRight, reduceRightIndexed Grouping Note: This lesson is very much a work in progress. To help make your life easier, this lesson shares examples for the most common methods that are available to sequential collections classes. Kotlin collections classes have many methods on them - many.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |