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

21
LINES

< > BotCompany Repo | #1032116 // n_fancy2UnlessZero - takes singular and plural

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

Libraryless. Click here for Pure Java version (3080L/17K).

static S n_fancy2UnlessZero(long l, S singular, S plural) {
  ret l == 0 ? "" : formatWithThousandsSeparator(l) + " " + trim(l == 1 ? singular : plural);
}

static S n_fancy2UnlessZero(Collection l, S singular, S plural) {
  ret n_fancy2UnlessZero(l(l), singular, plural);
}

static S n_fancy2UnlessZero(Map m, S singular, S plural) {
  ret n_fancy2UnlessZero(l(m), singular, plural);
}

static S n_fancy2UnlessZero(O[] a, S singular, S plural) {
  ret n_fancy2UnlessZero(l(a), singular, plural);
}

ifclass MultiSet
  static S n_fancy2UnlessZero(MultiSet ms, S singular, S plural) {
    ret n_fancy2UnlessZero(l(ms), singular, plural);
  }
endif

Author comment

Began life as a copy of #1012450

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032116
Snippet name: n_fancy2UnlessZero - takes singular and plural
Eternal ID of this version: #1032116/1
Text MD5: 0c8e3f4ea45368595218b0a8a2731b58
Transpilation MD5: 45158b6ded47673b811cb90dd9e3a64c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-14 01:44:52
Source code size: 666 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 149 / 213
Referenced in: [show references]