So in this method, the conditional for the while loop is something that I chose to remove as in line code and create a method which is called when needed. However, this first method does not work, and causes the application to silently lock up.
def getLineRows( rows, index ) {
def lineRows = [rows[index]]
def newOperator
def i = index + 1
if ( index <= ( rows.size() - 1 ) ) {
newOperator = false
This is the code in question.
while ( index <= ( rows.size() - 1 ) && !newOperator ) {
if ( rows[index].PGM_PROC_OPE.trim() == "" ||
( rows[index].PGM_PROC_TY == "OR" ||
rows[index].PGM_PROC_TY == "AN" ) ) {
lineRows << rows[i]
} else {
newOperator = true
}
i++
}
}
return lineRows
}
In this second, and visually identical method, I have simply created a method called moreRows(rows, index). There are two other method calls, however they have been eliminated from consideration through testing.
def moreRows( rows, index ) {
return index <= ( rows.size() - 1 )
}
What would cause this code below to function properly when the moreRows is used, rather than the method above, where moreRows is in line?
def getLineRows( rows, index ) {
def lineRows = [rows[index]]
def newOperator
def i = index + 1
if ( moreRows( rows, i ) ) {
newOperator = false
while ( moreRows( rows, i ) && !newOperator ) {
if ( operatorEmpty( rows, i ) || isSpecialProcType( rows, i ) ) {
lineRows << rows[i]
} else {
newOperator = true
}
i++
}
}
return lineRows
}
Aucun commentaire:
Enregistrer un commentaire