The corextensions package is made up of many extensions on core classes such as
To import this package, include the following code:
For example, the following lists a few of these extensions:
trueif an iterable has length 1.
Iterable.findSmallestWherereturns the smallest value in this iterable following a mapping to
trueif the length of this iterable is the same as the other iterable provided.
Iterable.countreturns the number of times a value is present in the iterable.
List.mapWithIndexreturns an iterable which has been mapped using this list, where we are provided with both the value at the index, and the index itself.
trueif the list has an element present more than once, checked by the equality operator
List.swapswaps two elements within the list.
List.allIndicesOfreturns all the indices of a value in the list.
trueif this set has the same values as the other set, in any order.
List<num>.sumreturns the sum of the numbers.
List<num>.productreturns the product of the numbers.
String.capitalisereturns the string with the first letter replaced with the original one in upper case.
String.removeExtraSpacereturns the string with whitespace removed from not just the start and the end, but also the middle, with the assumption that there should only be 1 space between 2 words.
String.splitByAllsplits the string by all the delimiters provided.
String.replaceLastreplaces the last occurence of a substring from the string.
Map.firstValueWherereturns the first value that satisfies the provided function.
Map.reverseflips keys and values.
On top of these, there is also the function
zipTwoLists which zips two lists in the provided order.