Skip to main content

Practice ยท 1 of 3

First or Default

Write firstOr(items, fallback) โ€” RETURN the first element or fallback when the list is empty. The RETURNED value must have the SAME type relationship as the input (works for any element kind, no coercion).

Difficulty: intermediate

Back to lesson: Practice: Generics โ€” Practice