On Wed, 27 Mar 2024 23:18:43 GMT, Marius Hanl <mh...@openjdk.org> wrote:

>> modules/javafx.controls/src/main/java/javafx/scene/control/MultipleSelectionModelBase.java
>>  line 773:
>> 
>>> 771:                         .collect(Collectors.toList());
>>> 772: 
>>> 773:                 sortedNewIndices.forEach(this::set);
>> 
>> Why do the double-iteration pattern here and not do the `peek` operation in 
>> a `forEach` like in the other 2 places?
>
> `forEach` is void, so we can not return a list afterwards.

You don't need to return a list, you create it ahead of time like was done in 
line 167

List<Integer> indices = new ArrayList<>();

and the add the elements in `forEach`.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1430#discussion_r1542145635

Reply via email to