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

18
LINES

< > BotCompany Repo | #1001954 // getString - getOpt with cast to string

JavaX fragment (include)

static S getString(Map map, O key) {
  ret map == null ? null : (S) map.get(key);
}

static S getString(L l, int idx) {
  ret (S) get(l, idx);
}

static S getString(O o, O key) {
  if (o instanceof Map) ret getString((Map) o, key);
  if (key instanceof S)
    ret (S) getOpt(o, (S) key);
  throw fail("Not a string key: " + getClassName(key));
}

static S mapMethodLike getString(S key, O o) {
  ret getString(o, (O) key);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lnbujpyubztb, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xfddqsrefgvo, yanjaxplzisb

No comments. add comment

Snippet ID: #1001954
Snippet name: getString - getOpt with cast to string
Eternal ID of this version: #1001954/2
Text MD5: 839433f822ce07b6b439dadfe2eacf7c
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-23 23:15:23
Source code size: 441 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 931 / 2546
Version history: 1 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1003889 - getMap
#1005404 - getLong - getOpt with cast to long (or 0)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1007140 - getFloat - getOpt with cast to Float
#1018901 - getList - getOpt with cast to List
#1021786 - getString_htmlEncode
#1021916 - getStringOpt - getOpt with optional cast to string
#1023539 - getStringDyn - getOptDyn with cast to string
#3000382 - Answer for ferdie (>> t = 1, f = 0)