In javascript, there's the common pattern of creating an anonymous function and immediately invoking it (usually this is called a self-executing anonymous function or an immediately-invoked function expression).
With Java 8 lambdas, is there a standard way to replicate this behaviour?
Something like (() -> doSomething())()
.
This question asks basically the same question, but for Java 7. I'm explicitly looking for constructs which utilize lambdas.
defineAnonymousClass
was unfortunately ambigous; in this context, saying "anonymous class" at all invariably plays into this pervasive and unhelpful myth. – Brian Goetz