4 ms·
stream.filter(p) requires wrapping checked exceptions in p, or altering the language so that they’re no longer checked. Same with Runnable.
by erik_seaberg 3y ago
stream.filter(p) requires wrapping checked exceptions in p, or altering the language so that they’re no longer checked. Same with Runnable.
- chii 3y agoor you start doing monads instead, where p operates on a monad (aka, the Optional type). Unfortunately, this ends up propagating out and your entire code base needs to also do this. Tho i reckon it will make your code better in the future, for a short term/temporary pain converting/adding breaking changes etc.
- erik_seaberg 3y agoYeah, switching to Scala or Kotlin would be the shortest path to do that.
- masklinn 3y agoYou could also alter the langage woth for exceptions transparency (swift has something like that with “rethrows“). I don’t think that’s close to sufficient to making checked exceptions work tho, let alone good.