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).

1  
static <A> Set<A> createOrAddToSet(Set<A> set, A a) {
2  
  if (set == null) set = new Set;
3  
  set.add(a);
4  
  ret set;
5  
}
6  
7  
static <A> Set<A> createOrAddToSet(Set<A> set, A... l) {
8  
  fOr (A a : l) set = createOrAddToSet(set, a);
9  
  ret set;
10  
}

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: 173 / 252
Version history: 2 change(s)
Referenced in: [show references]