andresmasegosa/OOP_F21

Alternative ways of looping Sets

Opened this issue · 0 comments

During Session8 when showing the exercise in DemoSet

You said something like there is only one way to loop through sets, that is with foreach

But it also possible with lambda

cards.forEach((card) -> System.out.println(card));

Which Intellij suggests to replace with method reference

cards.forEach(System.out::println);

Which I'm not sure of the syntax of ❓ but it looks clean and is a one-liner as well