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

9
LINES

< > BotCompany Repo | #1007299 // addAndReturn - add element to a collection and return the element

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

Libraryless. Click here for Pure Java version (39L/1K).

static <B, A extends B> A addAndReturn(Collection<B> c, A a) {
  if (c != null) c.add(a);
  ret a;
}

static <B, A extends B> A addAndReturn(L<B> c, int idx, A a) {
  if (c != null) c.add(idx, a);
  ret a;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007299
Snippet name: addAndReturn - add element to a collection and return the element
Eternal ID of this version: #1007299/2
Text MD5: 8d65f5aa8598c63a93e31fba0e204592
Transpilation MD5: ff6591912d2d87b9f79d44b56a4ebdb9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-27 04:34:17
Source code size: 215 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 565 / 676
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1015525 - removeAndReturn - remove element from a collection and return the element
#1018571 - addAndReturnCollection - add element to a collection and return the collection
#1023695 - addAndPrint - add element to a collection, print the element and return it
#1029021 - addAndReturnIfNew - add element to a collection and return the element if it was new (null otherwise)