8 ms·
This doesn't seem any different from try/catch? The syntax differences are minimal. I don't mind try/catch, but I agree that checked exceptions should be dropp
by stickfigure 2y ago
This doesn't seem any different from try/catch? The syntax differences are minimal.
I don't mind try/catch, but I agree that checked exceptions should be dropped. Exceptions are for exceptional situations, which are myriad and rarely need to be handled except at some upper level (return 500, show error dialog, etc).
- ivan_gammel 2y agoOh, that actually does look different. Switch expression with exceptions would allow compact use of checked exceptions in method chaining. List<URI> pages… var content = pages.stream().map(uri -> switch(fetch(uri)) { case Page model -> return model; case throws IOException -> return Page.notFound(uri); }).toList();