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

20
LINES

< > BotCompany Repo | #1033843 // Flattener

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

Libraryless. Click here for Pure Java version (4767L/27K).

sclass Flattener {
  new L out;
  
  *() {}
  *(O... l) { add(l); }
  
  void add(O o) {
    ifdef Flattener_debug
    print("add " + className(o));
    endifdef
         if (o cast O[])      for (x : o) add(x);
    else if (o cast Iterable) for (x : o) add(x);
    else if (o != null) out.add(o);
  }
  
  void add(O... l) { add((O) l); }
  
  L toList() { ret out; }
  O[] toArray() { ret toObjectArray(out); }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033843
Snippet name: Flattener
Eternal ID of this version: #1033843/8
Text MD5: 41197f4fb8f962f6a4ea5c8ef895a0d6
Transpilation MD5: 67eeca5d766063388cf09119b718aeee
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-07 00:22:00
Source code size: 433 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 149 / 276
Version history: 7 change(s)
Referenced in: [show references]