int x = 1;
Consumer<Object> f = (i) -> {
int x = 1; // invalid
};
vs.
Consumer<Object> f = (i) -> {
int x = 1;
};
int x = 1; // valid
Imagine those two blocks inside a method. Why is the second block valid?
This is very similar to normal Java scopes:
int i;
{
int i; // invalid
}
vs.
{
int i; // valid
}
int i;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With