Closed ilmari closed 1 year ago
In theory this can be done without adding another line by making the later line https://github.com/mojolicious/mojo/pull/2084/files#diff-d48a9dbb018a19b463cfae82ffb2a5fd0cfe0cf4a553c09f8aba1048aaaaba0aR78 instead say for shift @$items
but I don't know if that makes the line too long or too inscrutable. @kraih?
Either way, I approve
for shift @$items
Another option would be return () unless my ($item) = splice(@items, 0, 1);
, since splice
returns an empty list if the input is empty, and list assignment returns the number of items assigned, regardless of their truthiness.
The check for whether to call the callback returned early if the item was falsy. Instead, it needs to only return early if there are no items left.