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

15
LINES

< > BotCompany Repo | #1006693 // joinStrings - join non-empty strings with separator

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

Libraryless. Click here for Pure Java version (2718L/16K).

static S joinStrings(S sep, O... strings) {
  ret joinStrings(sep, Arrays.asList(strings));
}

static S joinStrings(S sep, Iterable strings) {
  new StringBuilder buf;
  for (O o : unnull(strings)) { 
    S s = strOrNull(o);
    if (nempty(s)) {
      if (nempty(buf)) buf.append(sep);
      buf.append(s);
    }
  }
  ret str(buf);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006693
Snippet name: joinStrings - join non-empty strings with separator
Eternal ID of this version: #1006693/3
Text MD5: 6d8a3fa6509928170495ce186c8f1223
Transpilation MD5: e089f4c08ae45f59a109c57a354f63ba
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-04 04:15:15
Source code size: 348 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 510 / 965
Version history: 2 change(s)
Referenced in: [show references]