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

11
LINES

< > BotCompany Repo | #1031246 // arrayTypeAndDimensions - get type of innermost element plus the arrays number of dimensions

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

Libraryless. Click here for Pure Java version (2862L/17K).

static Pair<Class, Int> arrayTypeAndDimensions(O o) {
  ret arrayTypeAndDimensions(_getClass(o));
}

static Pair<Class, Int> arrayTypeAndDimensions(Class c) {
  if (c == null || !c.isArray()) null;
  Class elem = c.getComponentType();
  if (elem.isArray())
    ret mapPairB(arrayTypeAndDimensions(elem), dim -> dim+1);
  ret pair(elem, 1);
}

Author comment

Began life as a copy of #1018917

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031246
Snippet name: arrayTypeAndDimensions - get type of innermost element plus the arrays number of dimensions
Eternal ID of this version: #1031246/2
Text MD5: 82ef786efeb162709d9747e11f39f303
Transpilation MD5: 3e33712f4a70a8aea4d06de3a84f8ee9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-25 17:40:20
Source code size: 351 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 188 / 260
Version history: 1 change(s)
Referenced in: [show references]