This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

When return statement is required in block (Lambda )

 
Ranch Hand
Posts: 32
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It confused me when i must use return statement in lamda expressions. Is it required or optional? In Study Guide (Jeanne and Scott) said return is required in block. Also they said there is compile error because of return in this code:


But there are some questions in Ethuware about select correct lambda expressions. The correct answers are lambda expressions without return statement. Only with semi-colons like this:

So i dont catch when i must use return in block
 
Saloon Keeper
Posts: 12275
259
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use return in a block when the method that the lambda implements has a return type other than void.

It looks like the processList() method requires a BiConsumer. The BiConsumer.accept() method returns void.
 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic