mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
introduce variable inside lambda: do not step out of lambda block
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ExtractVariableSample {
|
||||
interface I {
|
||||
void foo(String s);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Collection<String> strings = new ArrayList<>();
|
||||
I i = (s) -> {
|
||||
int j = s.hashCode();
|
||||
System.out.println(j); };
|
||||
|
||||
for (String s : strings) {
|
||||
System.out.println(s.hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ExtractVariableSample {
|
||||
interface I {
|
||||
void foo(String s);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Collection<String> strings = new ArrayList<>();
|
||||
I i = (s) -> { System.out.println(<selection>s.hashCode()</selection>); };
|
||||
|
||||
for (String s : strings) {
|
||||
System.out.println(s.hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user