Skip to content

Commit

Permalink
Add if missing bools
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberpwnn committed Jul 6, 2022
1 parent dd49efe commit 3608c32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/Amulet/extensions/java/util/List/XList.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ public static <E> E getRandom(@This List<E> self)
return self.getRandom(Random.r());
}

public static <E> void addIfMissing(@This List<E> self, E e)
{
public static <E> boolean addIfMissing(@This List<E> self, E e) {
if(!self.contains(e)) {
self.add(e);
return true;
}

return false;
}

public static <E> @Self List<E> where(@This List<E> self, Predicate<E> pred) {
Expand Down

0 comments on commit 3608c32

Please sign in to comment.