Transpiled version (9674L) is out of date.
1 | public static <A> S join(S glue, Iterable<A> strings) { |
2 | if (strings == null) ret ""; |
3 | if (strings cast Collection) { |
4 | if (strings.size() == 1) ret strOrEmpty(first(strings)); |
5 | } |
6 | new StringBuilder buf; |
7 | Iterator<A> i = strings.iterator(); |
8 | if (i.hasNext()) { |
9 | buf.append(strOrEmpty(i.next())); |
10 | while (i.hasNext()) |
11 | buf.append(glue).append(strOrEmpty(i.next())); |
12 | } |
13 | ret buf.toString(); |
14 | } |
15 | |
16 | public static S join(S glue, S... strings) { |
17 | ret join(glue, Arrays.asList(strings)); |
18 | } |
19 | |
20 | public static S join(S glue, O... strings) { |
21 | ret join(glue, Arrays.asList(strings)); |
22 | } |
23 | |
24 | static <A> S join(Iterable<A> strings) { |
25 | ret join("", strings); |
26 | } |
27 | |
28 | static <A> S join(Iterable<A> strings, S glue) { |
29 | ret join(glue, strings); |
30 | } |
31 | |
32 | public static S join(String[] strings) { |
33 | ret join("", strings); |
34 | } |
35 | |
36 | ifclass Pair |
37 | static S join(S glue, Pair p) { |
38 | ret p == null ? "" : str(p.a) + glue + str(p.b); |
39 | } |
40 | endif |
Began life as a copy of #2000507
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000810 |
Snippet name: | join function + array version |
Eternal ID of this version: | #1000810/15 |
Text MD5: | c9bf1e11a119ad1d80626ab26721ba7e |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-11-22 00:51:45 |
Source code size: | 952 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 1135 / 12535 |
Version history: | 14 change(s) |
Referenced in: | [show references] |