• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java 8's lambda placeholder variable leaks into the scope  RSS feed

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to fix the deficiency whereby local variables declared at the beginning of a scope cannot be shadowed transparently inside lambdas ?



This snippet does not compile.
 
Venkat Subramaniam
Author
Ranch Hand
Posts: 109
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lambdas use lexical scoping. Java is trying to protect us here from the confusion and the resulting errors.
It's more of a feature than a flaw or deficiency.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!