Libraryless. Click here for Pure Java version (2209L/14K).
1 | // now also takes a map as single array entry |
2 | static <A> A optPar_ignoreOddLength(O[] opt, S name, A defaultValue) { |
3 | int n = l(opt); |
4 | if (n == 1 && opt[0] instanceof Map) { |
5 | Map map = cast opt[0]; |
6 | ret map.containsKey(name) ? (A) map.get(name) : defaultValue; |
7 | } |
8 | for (int i = 0; i+1 < l(opt); i += 2) |
9 | if (eq(opt[i], name)) |
10 | ret (A) opt[i+1]; |
11 | ret defaultValue; |
12 | } |
13 | |
14 | sO optPar_ignoreOddLength(O[] opt, S name) { |
15 | ret optPar_ignoreOddLength(opt, name, null); |
16 | } |
17 | |
18 | sO mapMethodLike optPar_ignoreOddLength(S name, O[] params) { |
19 | ret optPar_ignoreOddLength(params, name); |
20 | } |
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: | 210 / 295 |
Referenced in: | [show references] |