lastOrElse method

E lastOrElse(
  1. E defaultValue
)

Last element or defaultValue if the collection is empty.

Implementation

E lastOrElse(E defaultValue) => isNotEmpty ? last : defaultValue;