firstOrNull()
works nicely with the Elvis operator (?:
). You get
either the first matching item in the list or whatever the right side
of the Elvis operator evaluates to. This functions as a way of getting
a default value if the list does not contain a matching item.
You can learn more about this in:
Tags: