Skip to content

Commit

Permalink
GROOVY-11308: DefaultGroovyMethods#unique now returns null for empty …
Browse files Browse the repository at this point in the history
…or 1 element input (minor refactor)
  • Loading branch information
paulk-asert committed Feb 14, 2024
1 parent a43d5d4 commit fac098f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14580,11 +14580,14 @@ public static <T> List<T> unique(List<T> self) {
* @since 1.8.1
*/
public static <T> Collection<T> unique(Collection<T> self, boolean mutate) {
Objects.requireNonNull(self);
if (!mutate && self.size() <= 1) {
return self;
}
Collection<T> answer = uniqueItems(self);
if (mutate) {
self.clear();
self.addAll(answer);

return self;
} else {
return answer;
Expand Down

0 comments on commit fac098f

Please sign in to comment.