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

15
LINES

< > BotCompany Repo | #1000918 // smartJoin (for joining command line arguments)

JavaX fragment (include)

// Try to get the quoting right...

sS smartJoin(S[] args) {
  if (empty(args)) ret "";
  if (args.length == 1) return args[0];
  
  S[] a = new S[args.length];
  for (int i = 0; i < a.length; i++)
    a[i] = !isJavaIdentifier(args[i]) && !isQuoted(args[i]) ? quote(args[i]) : args[i];
  return join(" ", a);
}

static S smartJoin(L<S> args) {
  ret smartJoin(toStringArray(args));
}

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: #1000918
Snippet name: smartJoin (for joining command line arguments)
Eternal ID of this version: #1000918/3
Text MD5: da60739f4d322220e3609584ec9663ac
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-25 17:10:15
Source code size: 397 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 591 / 855
Version history: 2 change(s)
Referenced in: [show references]