smallestOccurrence method
T?
smallestOccurrence()
Finds the smallest occurrence in the list.
Returns the smallest element in the list based on the Comparable implementation.
Implementation
T? smallestOccurrence() {
// check if the list is empty before calling reduce
if (isEmpty) {
return null;
}
return reduce((T value, T element) => value.compareTo(element) < 0 ? value : element);
}