Libraryless. Click here for Pure Java version (3135L/17K).
1 | static S n2UnlessZero(long l) { ret l == 0 ? "" : formatWithThousands(l); }
|
2 | static S n2UnlessZero(Collection l) { ret n2UnlessZero(l(l)); }
|
3 | static S n2UnlessZero(Map map) { ret n2UnlessZero(l(map)); }
|
4 | |
5 | sS n2UnlessZero(double l, S singular) {
|
6 | ret n2UnlessZero(l, singular, singular + "s"); |
7 | } |
8 | |
9 | sS n2UnlessZero(double l, S singular, S plural) {
|
10 | if (fraction(l) == 0) |
11 | ret n2UnlessZero((long) l, singular, plural); |
12 | else |
13 | ret l + " " + plural; |
14 | } |
15 | |
16 | static S n2UnlessZero(long l, S singular, S plural) {
|
17 | ret n_fancy2UnlessZero(l, singular, plural); |
18 | } |
19 | |
20 | static S n2UnlessZero(long l, S singular) {
|
21 | ret n_fancy2UnlessZero(l, singular, singular + "s"); |
22 | } |
23 | |
24 | static S n2UnlessZero(Collection l, S singular) {
|
25 | ret n2UnlessZero(l(l), singular); |
26 | } |
27 | |
28 | static S n2UnlessZero(Collection l, S singular, S plural) {
|
29 | ret n_fancy2UnlessZero(l, singular, plural); |
30 | } |
31 | |
32 | static S n2UnlessZero(Map m, S singular, S plural) {
|
33 | ret n_fancy2UnlessZero(m, singular, plural); |
34 | } |
35 | |
36 | static S n2UnlessZero(Map m, S singular) {
|
37 | ret n2UnlessZero(l(m), singular); |
38 | } |
39 | |
40 | static S n2UnlessZero(long[] a, S singular) { ret n2UnlessZero(l(a), singular); }
|
41 | |
42 | static S n2UnlessZero(O[] a, S singular) { ret n2UnlessZero(l(a), singular); }
|
43 | static S n2UnlessZero(O[] a, S singular, S plural) { ret n_fancy2UnlessZero(a, singular, plural); } |
Began life as a copy of #1012632
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
| Snippet ID: | #1032117 |
| Snippet name: | n2UnlessZero - empty string when number is zero |
| Eternal ID of this version: | #1032117/3 |
| Text MD5: | 5928c6924b654743c9b0c5aa8f574099 |
| Transpilation MD5: | d88a3f3765e8fb8c2953e01ee4805a72 |
| 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:46:31 |
| Source code size: | 1347 bytes / 43 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 339 / 444 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |