Take a function that requires a value of T and return a version that takes Optional<T>
T
Optional<T>
NB: If an empty Optional is passed to the new function, a NoSuchElementException will be thrown
Optional
NoSuchElementException
Take a function that requires a value of
Tand return a version that takesOptional<T>NB: If an empty
Optionalis passed to the new function, aNoSuchElementExceptionwill be thrown