I'm learning Java 8 Lambda expressions. I got the basic understanding of Lambda. But I don't understand how following code is working for the code snippet:-
return new Quote(quote,
stock.getQuote().getPrice()); // Confusion here.
Does this return to the following function which is .collect(Collectors.toList()) or return from the Lambda completely. Please explain in details how does it work?
public List<Quote> getStock(){
List<String> quotes = new ArrayList<>();
return quotes
.stream()
.map(quote -> {
Stock stock = getStockPrice(quote);
return new Quote(quote, stock.getQuote().getPrice()); // Confusion here
})
.collect(Collectors.toList());
}