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

18
LINES

< > BotCompany Repo | #1018901 // getList - getOpt with cast to List

JavaX fragment (include)

1  
static L getList(Map map, O key) {
2  
  ret map == null ? null : (L) map.get(key);
3  
}
4  
5  
static L getList(L l, int idx) {
6  
  ret (L) get(l, idx);
7  
}
8  
9  
static L getList(O o, O key) {
10  
  if (o instanceof Map) ret getList((Map) o, key);
11  
  if (key instanceof S)
12  
    ret (L) getOpt(o, (S) key);
13  
  throw fail("Not a string key: " + getClassName(key));
14  
}
15  
16  
static L mapMethodLike getList(S name, O o) {
17  
  ret getList(o, name);
18  
}

Author comment

Began life as a copy of #1001954

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, elmgxqgtpvxh, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1018901
Snippet name: getList - getOpt with cast to List
Eternal ID of this version: #1018901/3
Text MD5: 9db0d291fba89a0407ad50c6dfa7ceac
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-20 14:19:26
Source code size: 427 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 372 / 427
Version history: 2 change(s)
Referenced in: [show references]