1 | static <A> A getSingleton(L<A> l) { |
2 | assertEquals(1, l(l)); |
3 | ret first(l); |
4 | } |
5 | |
6 | static <A> A getSingleton(A[] l) { |
7 | assertEquals(1, l(l)); |
8 | ret first(l); |
9 | } |
10 | |
11 | ifclass IMultiSet |
12 | static <A> A getSingleton(IMultiSet<A> ms) { |
13 | assertEquals(1, l(ms)); |
14 | ret first(ms); |
15 | } |
16 | endif |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005176 |
Snippet name: | getSingleton - assert a list/array has exactly one element and get it |
Eternal ID of this version: | #1005176/5 |
Text MD5: | e5882a032889dfb951d496a3e865201b |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-02-13 23:23:03 |
Source code size: | 287 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 645 / 659 |
Version history: | 4 change(s) |
Referenced in: | [show references] |