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

18
LINES

< > BotCompany Repo | #1026306 // StringBuilderWithIndent

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

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

1  
sclass StringBuilderWithIndent {
2  
  new StringBuilder buf;
3  
  S indent = "";
4  
  
5  
  void println(O o) {
6  
    buf.append(indentx(indent, o + "\n"));
7  
  }
8  
  
9  
  AutoCloseable indent() {
10  
    S oldIndent = indent;
11  
    indent += "  ";
12  
    ret autoCloseable { indent = oldIndent; };
13  
  }
14  
  
15  
  //void unindent() { indent = dropLast(2, indent); }
16  
  
17  
  toString { ret str(buf); }
18  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1026306
Snippet name: StringBuilderWithIndent
Eternal ID of this version: #1026306/4
Text MD5: 066c6c8fd01635982e6e3f31c5fd14e5
Transpilation MD5: 6d227c61ac38eda9128c9be9c39df2f5
Author: stefan
Category: javax / discord
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-12-15 17:12:56
Source code size: 381 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 120 / 459
Version history: 3 change(s)
Referenced in: [show references]