Campbell Ritchie wrote:Go back to the Manning link I gave you and read that chapter. The principal idea of FP is probably that you are not allowed any side‑effects.
You can reduce the λs in JB's code with method references. I shall leave that to YI as an exercise.
Jason Bullers wrote: ...
It is worth going through that code for the types of each line. To start: there are different indentation conventions. Ken Kousen says to align each dot for each intermediate operation in a vertical column as above (I used your code plus an extra space), and Urma Fusco and Mycroft align all the dots, as you did after the terminal operation in line 4. So let's look at the lines.
salvin francis wrote:. . .
Campbell Ritchie wrote:3: .... I am 99% sure you can replace that λ with a method reference Something::isAdult. Returns a second IntStream...
Jason Bullers wrote:... but if it's part of a public API, I'd prefer to just send the Optional back to the caller and let them handle it as they like...
salvin francis wrote:... That's sounds good too. I hope OP has learnt a few good things from this post. I know I have !
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your databasehttps://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database