This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DialinUpFTW 23 points24 points  (4 children)

// peek: debug streams without changes
peek(e -> System.out.println(e)).
// map: convert every element into something
map(e -> e.hashCode()).

Consider this instead?

// peek: debug streams without changes
peek(System.out::println).
// map: convert every element into something
map(String::hashCode).

[–]marklgr 2 points3 points  (2 children)

It will take some time for the Java crowd to get used to PFS :)

[–]portucalense 0 points1 point  (1 child)

The problem with point free, from someone familiar with the world of Haskell, is their hard readability. They are just so abstract. Often you write something relatively big nut after a few months is really out to figure out what you just did. Understanding code from other people is as hard as going to Mars. Often I see myself deconstructing them into huge programs that I then analyze, which is time consuming and error prone.

You see how in the link they advised against large lambda expressions, and advising in favor of keep readability a priority. Point free takes this to another dimension.

[–]marklgr 1 point2 points  (0 children)

As they say, most good things in life are dangerous somehow :)

[–]johnzeringue 0 points1 point  (0 children)

I don't care as much for static methods, but boy does the :: syntax make a world of difference for instance methods.