Jeremypw/gtk4 prep/bookmark list box cleanup#2540
Conversation
danirabbit
left a comment
There was a problem hiding this comment.
Just a tiny comment/question/nitpick otherwise this LGTM
| int index = 0; | ||
| Gtk.ListBoxRow? row = list_box.get_row_at_index (index++); |
There was a problem hiding this comment.
You start the index at 0 but then immediately make it 1 here. That seems a bit overcomplicated? Why not just start the index where you need it to start? 😅 Also does the row index start at 1? Do we not start at 0?
There was a problem hiding this comment.
Unless I'm mistaken, when ++ is post-fixed it operates after the variable is used so the current code is equivalent to
Gtk.ListBoxRow? row = list_box.get_row_at_index (index);
index = index + 1;
(when the operator is pre-fixed it increments the variable before using it)
I'll double-check though and see if there is a clearer, equally concise way.
|
@danirabbit
So with the postfix operator the lookup expression uses the original (pre-incremented) value as I expected. |
|
Now used the pre-fix operator which requires the same number of lines and is clearer. Not sure why I used the post-fix tbh |
Use equivalent code that will work in Gtk4 as well as Gtk3 as far as possible