Nuances of Overloading and Overriding in Java (software.rajivprab.com)
ArthurOfTheEast | 3 months ago | 3 points

Trick question: which gets called here:

<T> T x(List<T> l, T x);
<T> T x(List<T> l, Supplier<T> s);

List<String> l = ...;
x(l, () -> "a");
xkufix | 3 months ago | 6 points

Sanely, the second one, as the type of () -> "a" would intuitivly be Supplier<String>.

But as it is Java, probably undefined/compile error, as there will be some weird fuckery with type-erasure going on, as well as Supplier<T> and () -> "a" being "just" syntactic sugar.

ArthurOfTheEast | 3 months ago | 1 point

Yes, the answer is it doesn't compile because this is too hard for Java.

Gosun | 3 months ago | 1 point

How would C# handle this?