파라미터를 쓰지 않는 표현법을, 우리 팀 시니어 엔지니어가 자주 활용하길래.
물어본적이 있다.
이런 식인데, 아는 사람은 잘 알겠지만, 나는 아직 자바에 익숙치 않아서 찾아보았다.
https://javarevisited.blogspot.com/2014/02/10-example-of-lambda-expressions-in-java8.html
링크를 찾아가서 보면, 아래 쯤에 이런 문구가 있다.
---------------------
2) You can use method reference inside lambda expression if method is not modifying the parameter supplied by lambda expression. For example following lambda expression can be replaced with a method reference since it is just a single method call with the same parameter:
list.forEach(n -> System.out.println(n));
list.forEach(System.out::println); // using method reference
However, if there’s any transformations going on with the argument, we can’t use method references and have to type the full lambda expression out, as shown in below code :
list.forEach((String s) -> System.out.println("*" + s + "*"));
You can actually omit the type declaration of lambda parameter here, compiler is capable to infer it from generic type of List.