Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

10
LINES

< > BotCompany Repo | #1032548 // createOrAddToSet (defaults to HashSet)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4577L/25K).

static <A> Set<A> createOrAddToSet(Set<A> set, A a) {
  if (set == null) set = new Set;
  set.add(a);
  ret set;
}

static <A> Set<A> createOrAddToSet(Set<A> set, A... l) {
  fOr (A a : l) set = createOrAddToSet(set, a);
  ret set;
}

Author comment

Began life as a copy of #1021803

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032548
Snippet name: createOrAddToSet (defaults to HashSet)
Eternal ID of this version: #1032548/3
Text MD5: 1024e5a41ce09b7e69b13a96a28b5b9a
Transpilation MD5: 828dfc1936e4d0e7fce926893a11de56
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-08 21:54:21
Source code size: 242 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 172 / 250
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1034452 - createOrAddToSyncLinkedHashSet