Hacker News new | ask | show | jobs
by mypalmike 1432 days ago
I'm generally a proponent of OO, and I actually think this kind of filtering chain is one of a number of places where fp code can be more readable than imperative loops.
1 comments

It's also, more or less, the "fluent interface" style if laid out differently, other than the lambdas (but even those are in both C# and Java):

  timeslotRepo.findAll()
    .stream()
    .filter(timeslot->timeslot.getEndDate()==null)
    .first()
    .ifPresentOrElse(()->{}, ()->{new Timeslot(DateTime.now())})
https://en.wikipedia.org/wiki/Fluent_interface#Java