2 ms·
> Not sure `getWhenPresent()` is better. Maybe `unsafeGet()`? That's a pattern found a lot on functional structures such as `IO` or `Task`. It's not unsafe, it
by masklinn 11y ago
> Not sure `getWhenPresent()` is better. Maybe `unsafeGet()`? That's a pattern found a lot on functional structures such as `IO` or `Task`.
It's not unsafe, it safely throws an error when the optional is empty.
There already is a #orElseThrow(Exception), there could be a #orElseThrow() defaulting to raising NoSuchElementException.