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

15
LINES

< > BotCompany Repo | #1002621 - toInt

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2158L/14K).

static int toInt(O o) {
  if (o == null) ret 0;
  if (o cast Number)
    ret o.intValue();
  if (o cast S)
    ret parseInt(o);
  if (o cast Bool)
    ret boolToInt(o);
  throw fail("woot not int: " + getClassName(o));
}

static int toInt(long l) {
  if (l != (int) l) fail("Too large for int: " + l);
  ret (int) l;
}

download  show line numbers  debug dex   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, sawdedvomwva, tslmcundralx, tvejysmllsmz, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1002621
Snippet name: toInt
Eternal ID of this version: #1002621/3
Text MD5: 8294c654949d3c90652aefd682dd0488
Transpilation MD5: 5c00ea5cefb847edd0ec3e26140e0cb0
Author: stefan
Category: javax / eleu
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-11 20:28:59
Source code size: 332 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 460 / 1248
Version history: 2 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1002621 & http://1002621.tinybrain.de