Comment

Comment by layer8

No, but you can have an interface like

    interface Func<P, R, X extends Exception>
    {
        R func(P param) throws X;
    }
or the same with more than one exception type, and convert your lambda to that. This works. The only problem is that you can’t abstract over an arbitrary number of exception types.

In principle, one could imagine a syntax for variadic type parameters like

    interface Func<P..., R, X... extends Exception>
    {
        R func(P... params) throws X...;
    }
that would solve that problem.
parent layer8 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton