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

14
LINES

< > BotCompany Repo | #1036936 // betterGetIndent - getIndent + handling empty lines better

JavaX fragment (include)

static int betterGetIndent(S s) {
  int n = Int.MAX_VALUE;
  for (line : linesIterator(s)) {
    line = rtrim(line);
    if (nempty(line)) {
      int indent = getIndentOfLine(line);
      if (indent < n) {
        n = indent;
        if (n == 0) ret 0;
      }
    }
  }
  ret n;
}

Author comment

Began life as a copy of #1002854

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036936
Snippet name: betterGetIndent - getIndent + handling empty lines better
Eternal ID of this version: #1036936/5
Text MD5: d85d61e1fdad3ad0fb439267bddd776b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-07-24 21:33:56
Source code size: 297 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 117 / 156
Version history: 4 change(s)
Referenced in: #761 - New #629 - Standard functions list (LIVE) - continued on #1006654