1 | // now also takes a map as single array entry |
2 | static <A> A mapMethodLike optParOr(S name, O[] opt, IF0<A> defaultFunction) {
|
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) : callF(defaultFunction); |
7 | } |
8 | if (!even(l(opt))) fail("Odd parameter length");
|
9 | for (int i = 0; i < l(opt); i += 2) |
10 | if (eq(opt[i], name)) |
11 | ret (A) opt[i+1]; |
12 | ret callF(defaultFunction); |
13 | } |
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: | #1023031 |
| Snippet name: | optParOr |
| Eternal ID of this version: | #1023031/3 |
| Text MD5: | 6762fc9bdab772fabfdd98a6fffe8eed |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-04-23 13:35:07 |
| Source code size: | 473 bytes / 13 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 656 / 718 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |