java - Is there a way to compare lambdas? -
say have list of object defined using lambda expressions (closures). there way inspect them can compared? the code interested in is list<strategy> strategies = getstrategies(); strategy = (strategy) this::a; if (strategies.contains(a)) { // ... the full code is import java.util.arrays; import java.util.list; public class closureequalsmain { interface strategy { void invoke(/*args*/); default boolean equals(object o) { // doesn't compile return closures.equals(this, o); } } public void a() { } public void b() { } public void c() { } public list<strategy> getstrategies() { return arrays.aslist(this::a, this::b, this::c); } private void teststrategies() { list<strategy> strategies = getstrategies(); system.out.println(strategies); strategy = (strategy) this::a; // prints false system.out.println("strategies.contains(thi...