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

10
LINES

< > BotCompany Repo | #1030346 // indentWidth

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

Libraryless. Click here for Pure Java version (2529L/16K).

1  
static int indentWidth(int spacesPerTab default 2, S s) {
2  
  int count = 0, n = l(s);
3  
  for i to n: {
4  
    char c = s.charAt(i);
5  
    if (c == ' ') ++count;
6  
    else if (c == '\t') count += spacesPerTab;
7  
    else break;
8  
  }
9  
  ret count;
10  
}

Author comment

Began life as a copy of #1020372

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1030346
Snippet name: indentWidth
Eternal ID of this version: #1030346/1
Text MD5: cbd038ed7bbd497e02da53bd1684c191
Transpilation MD5: 1e590e70bae85a239efa3321be565104
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-12-05 20:47:23
Source code size: 244 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 175 / 250
Referenced in: [show references]