Libraryless. Click here for Pure Java version (7648L/43K).
static <A> A singletonOpt(Collection<A> l) { ret l(l) == 1 ? first(l) : null; } static <A> A singletonOpt(A[] l) { ret l(l) == 1 ? first(l) : null; }
Began life as a copy of #1005177
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: | #1015727 |
Snippet name: | singletonOpt - synonym of getSingletonOpt - return single elemtent of list if length == 1 or null otherwise |
Eternal ID of this version: | #1015727/4 |
Text MD5: | 900e5dccd8ef05d6aac3429dd0520f0d |
Transpilation MD5: | 9b605d3822dd6d11326dd1f59eac65b4 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-04-02 18:05:41 |
Source code size: | 160 bytes / 7 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 429 / 525 |
Version history: | 3 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1025313 - first_warnIfMultiple - get first element of list; warn() when more than one element |