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

11
LINES

< > BotCompany Repo | #1002091 // nullIfEmpty - convert empty thing to null

JavaX fragment (include)

static S nullIfEmpty(S s) {
  ret isEmpty(s) ? null : s;
}

static <A, B> Map<A, B> nullIfEmpty(Map<A, B> map) {
  ret isEmpty(map) ? null : map;
}

static <A> L<A> nullIfEmpty(L<A> l) {
  ret isEmpty(l) ? null : l;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002091
Snippet name: nullIfEmpty - convert empty thing to null
Eternal ID of this version: #1002091/7
Text MD5: 3e38bf16fdbb23f164f7e2848d323434
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-01 15:24:59
Source code size: 227 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 708 / 1055
Version history: 6 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1021984 - nullIfSingleton
#1032736 - nullIfEmpty_gen - convert empty thing to null
#1035192 - str_nullIfEmpty - convert to string, empty string becomes null
#3000382 - Answer for ferdie (>> t = 1, f = 0)