On Thu, 3 Nov 2022 16:23:51 GMT, Andy Goryachev <[email protected]> wrote:

>> What I mean by code simplification is -
>> 
>>         boolean isAlreadySelected = false;
>>         MultipleSelectionModel<?> sm = getSelectionModel();
>>         if (sm != null) {
>>             isAlreadySelected = sm.isSelected(index);
>> 
>>             if (isAlreadySelected && shortcutDown) {
>>                 sm.clearSelection(index);
>>                 getFocusModel().focus(index);
>>                 isAlreadySelected = false;
>>             } else {
>>                 sm.clearAndSelect(index);
>>             }
>>         }
>
> in this version, there are code paths where you assign the same variable 
> twice.  I don't do that, I don't like doing that.  Is this required or in the 
> code style?

It may not be the code style requirement, but generally, it is a good practice 
to initialize the variable explicitly at the time of declaration. My version 
saves an `else` block as well.
Anyway, I will not insist on this as it is a trivial code style preference.

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

PR: https://git.openjdk.org/jfx/pull/876

Reply via email to