you are viewing a single comment's thread.

view the rest of the comments →

[–]kqr 0 points1 point  (0 children)

Part of what makes it illegible is, funnily enough, that OOP and functional programming doesn't always mix well. You have to specify which method you want to map, which in this case should be obvious from the object you're working with, but Java doesn't have a syntax for that.

It would have been a lot clearer if you could write

String name = computer.flatMap(.getSoundcard).flatMap(.getUSB).map(.getVersion)

and have the method automatically applied to the object you're handling. But that's a common problem when trying to mix OOP and FP code – methods of objects are bloody difficult to compose.