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

28
LINES

< > BotCompany Repo | #1002415 // structureLines - now calls structureForUser

JavaX fragment (include)

// Try to put the structure in multiple lines
// (works for List and Map)
// For other values, defaults to structure()
static S structureLines(O data) {
  if (data instanceof O[]) data = asList((O[]) data);
  
  if (data instanceof Collection) {
    new L<S> l;
    for (O x : (Collection) data)
      l.add(structureForUser(x));
    ret fromLines(l);
  }
  
  ifclass MultiSet
  if (data instanceof MultiSet) data = multiSetToMap(data/MultiSet);
  endif
  
  if (data instanceof Map) {
    new L<S> l;
    for (O key : ((Map) data).keySet()) {
      O value = ((Map) data).get(key);
      l.add(structureForUser(key) + " = " + structureForUser(value));
    }
    ret fromLines(l);
  }
  
  ret structureForUser(data);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1002415
Snippet name: structureLines - now calls structureForUser
Eternal ID of this version: #1002415/5
Text MD5: 4595ee4d9dc642811fef9ec681b33f7d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-20 12:34:33
Source code size: 747 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 673 / 1082
Version history: 4 change(s)
Referenced in: [show references]