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

20
LINES

< > BotCompany Repo | #1027361 // optPar_ignoreOddLength

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

Libraryless. Click here for Pure Java version (2209L/14K).

// now also takes a map as single array entry
static <A> A optPar_ignoreOddLength(O[] opt, S name, A defaultValue) {
  int n = l(opt);
  if (n == 1 && opt[0] instanceof Map) {
    Map map = cast opt[0];
    ret map.containsKey(name) ? (A) map.get(name) : defaultValue;
  }
  for (int i = 0; i+1 < l(opt); i += 2)
    if (eq(opt[i], name))
      ret (A) opt[i+1];
  ret defaultValue;
}

sO optPar_ignoreOddLength(O[] opt, S name) {
  ret optPar_ignoreOddLength(opt, name, null);
}

sO mapMethodLike optPar_ignoreOddLength(S name, O[] params) {
  ret optPar_ignoreOddLength(params, name);
}

Author comment

Began life as a copy of #1007397

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1027361
Snippet name: optPar_ignoreOddLength
Eternal ID of this version: #1027361/1
Text MD5: be33bfb6eb9ff0cf56a58121360d96ee
Transpilation MD5: dfbdd2f8da03889c97b8e928c8f5ddf3
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-11 19:00:16
Source code size: 607 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 209 / 294
Referenced in: [show references]