Libraryless. Click here for Pure Java version (1629L/11K).
1 | static <A> A mapMethodLike optPar_func(S name, O[] opt, IF0<A> defaultValue) {
|
2 | int n = l(opt); |
3 | if (n == 1 && opt[0] instanceof Map) {
|
4 | Map map = cast opt[0]; |
5 | ret map.containsKey(name) ? (A) map.get(name) : callF(defaultValue); |
6 | } |
7 | if (!even(l(opt))) fail("Odd parameter length");
|
8 | for (int i = 0; i < l(opt); i += 2) |
9 | if (eq(opt[i], name)) |
10 | ret (A) opt[i+1]; |
11 | ret callF(defaultValue); |
12 | } |
Began life as a copy of #1006679
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1024299 |
| Snippet name: | optPar_func |
| Eternal ID of this version: | #1024299/4 |
| Text MD5: | 87fa4fc970f4e58d9ddd4d506a10f3da |
| Transpilation MD5: | 912adeb66aa16d186dff9df67874ac00 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-07-30 15:24:15 |
| Source code size: | 420 bytes / 12 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 427 / 541 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |