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

17
LINES

< > BotCompany Repo | #1021902 // litparams - make object array for params (key/value/key/value...), dropping null values

JavaX fragment (include)

static O[] litparams(O... l) {
  int n = 0, n1 = l(l);
  for (int i = 0; i < n1; i += 2)
    if (l[i] != null && l[i+1] != null)
      ++n;
  if (n == 0) null;
  O[] params = new O[n*2];
  int j = 0;
  for (int i = 0; i < n1; i += 2) {
    O key = l[i], value = l[i+1];
    if (key != null && value != null) {
      params[j++] = key;
      params[j++] = value;
    }
  }
  ret params;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021902
Snippet name: litparams - make object array for params (key/value/key/value...), dropping null values
Eternal ID of this version: #1021902/1
Text MD5: 2f38a3cacd15425aa75673a68b5f06f3
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-03 12:09:30
Source code size: 403 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 269 / 296
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1022195 - litmapparams