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

7
LINES

< > BotCompany Repo | #1023744 // joinWithCommaOr - join with ", " separator, return alternative string when list is empty

JavaX fragment (include)

static <A> S joinWithCommaOr(S def, Collection<A> c) {
  ret nempty(c) ? joinWithComma(c) : def;
}

static <A> S joinWithCommaOr(Collection<A> c, S def) {
  ret joinWithCommaOr(def, c);
}

Author comment

Began life as a copy of #1009156

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023744
Snippet name: joinWithCommaOr - join with ", " separator, return alternative string when list is empty
Eternal ID of this version: #1023744/4
Text MD5: 4cb34dfbf43d0a2f92bdd8e8a823071d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-01 20:03:28
Source code size: 189 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 181 / 233
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)