Talk:Computer Programming/Coding Style/Minimize nesting

Arrow shape, IF, is a STANDARD method, Any real coder, can tell, this article, is full of errors.

Any Real Coder, can tell, It is MUCH harder to read, your suggested, other methods.

Example, MAC, Swift 4, Validate and Convert SRT subtitle text file, Regex, shorter, harder to read.

func getSubTitleArrayFrom(thisFullPath: String)->[SubTitleLineSet] {   var subTitleSets    = [SubTitleLineSet] let subTitleLines  = linesFromTextFile(fullPath:  thisFullPath ) // Swift.print(subTitleLines.count) // Set Validate and Increment var setCounter : Int! = 0   var gotTime     : Bool! = false var gotText    : Bool! = false var textCnt    : Int! = 0   // Set to Flush var lastTxt            : String! = ""   var lastStartTimeInSec  : Double! = 0   var lastEndTimeInSec    : Double! = 0   for aLine in subTitleLines {       // Swift.print(aLine) var strComps = aLine.components(separatedBy: "-->") if strComps.count == 2 {

// Flush last if gotText == true && gotTime == true {               // Create Dictionary stime, etime, text // Swift.print( String(format:"%.3f : %.3f \n%@", lastStartTimeInSec, lastEndTimeInSec, lastTxt ) ) let item       = SubTitleLineSet item.startTime = lastStartTimeInSec item.endTime   = lastEndTimeInSec item.txt       = lastTxt subTitleSets.append(item) setCounter = setCounter + 1 lastTxt    = "" gotText    = false gotTime    = false textCnt    = 0 }           // hh:mm:ss,nnn strComps[0] = strComps[0].trimmingCharacters(in: CharacterSet.whitespaces ) strComps[1] = strComps[1].trimmingCharacters(in: CharacterSet.whitespaces ) let stimeComps = strComps[0].components(separatedBy: [":",","]) let etimeComps = strComps[1].components(separatedBy: [":",","]) if etimeComps.count == 4 && stimeComps.count == 4 {               var d2 : Double? = nil var d3 : Double? = nil var d4 : Double? = nil var d1 : Double? = Double(stimeComps[0]) if d1 != nil {                   d2 = Double(stimeComps[1]) if d2 != nil {                       d3 = Double(stimeComps[2]) if d3 != nil {                           d4 = Double(stimeComps[3]) if d4 != nil {                               lastStartTimeInSec = (d1! * 60 * 60) lastStartTimeInSec = lastStartTimeInSec + (d2! * 60) lastStartTimeInSec = lastStartTimeInSec + d3! lastStartTimeInSec = lastStartTimeInSec + (d4! * 0.001) d1 = Double(etimeComps[0]) if d1 != nil {                                   d2 = Double(etimeComps[1]) if d2 != nil {                                       d3 = Double(etimeComps[2]) if d3 != nil {                                           d4 = Double(etimeComps[3]) if d4 != nil {                                               lastEndTimeInSec =  d1! * 60 * 60                                               lastEndTimeInSec = lastEndTimeInSec +   d2! * 60                                               lastEndTimeInSec = lastEndTimeInSec +  d3! lastEndTimeInSec = lastEndTimeInSec +  d4! * 0.001                                               gotTime = true }                                       }                                    }                                }                            }                        }                    }                } // Both timestamps valid } // 4 plus 4 } // 2 Components else {           // Text (component --> not 2) Append Lines if aLine.count > 1 && gotTime == true {               textCnt = textCnt + 1

if textCnt < 2 {                   lastTxt = lastTxt + aLine + "\n" gotText = true }           }        }    }    //  Flush last if gotText == true && gotTime == true {       // Swift.print( String(format:"%.3f : %.3f \n%@", lastStartTimeInSec, lastEndTimeInSec, lastTxt ) ) let item       = SubTitleLineSet item.startTime = lastStartTimeInSec item.endTime   = lastEndTimeInSec item.txt       = lastTxt subTitleSets.append(item) }   return subTitleSets }

Note: My IP address is not exactly, a secret, Still, I can block any site that try to put something, on my computer.