Local Functional Interfaces

Olena Syrota sirotae at gmail.com
Mon Sep 23 12:27:04 PDT 2013

Dear lambda dev team,

Recently I made experiments with lamdas and found exotic case.
I was not able to declare local interface to make a "local" lambda-function.

Why I needed this.
Suppose I was to implement "local" lamdba-function to be used only couple
of times inside my method.
Compiler did not allowed me to place interface inside function.
In my case it was interface Dropper to implement lambda-function that drops
last element.

void myMethod(...) {

Interface Dropper { dropLastSymbolInChain (List<List<String>> chain);}
Dropper d = x -> x.stream()
.map(e->e.subList(0, e.size()-2))

List<List<String>> chain1Dropped = d.dropLastSymbolInChain(chain1);
List<List<String>> chain2Dropped = d.dropLastSymbolInChain(chain2);

I was forced to declare interface Dropper outside myMethod.

Should the proposition on local interfaces be submitted to jep?

Thank you.

More information about the lambda-dev mailing list