3 ms·
Not sure `getWhenPresent()` is better. Maybe `unsafeGet()`? That's a pattern found a lot on functional structures such as `IO` or `Task`. There could be a dis
by dudul 11y ago
Not sure `getWhenPresent()` is better. Maybe `unsafeGet()`? That's a pattern found a lot on functional structures such as `IO` or `Task`.
There could be a discussion to remove `get` altogether, but I don't think it would be a good idea. I don't use the Java type, but `scala.Option` and I think `get` is occasionally helpful in unit tests, scripts, etc.
- 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.