I have the following code:
def veifySequence() {
boolean checkB(list) {
def WEIGHTS = [ 10, 10.5, 11, 11.5, 12, 12.5, 13, 13.5, 1, 1.5, 2, 2.5, 3 ]*.toDouble().asImmutable()
list == list.toSorted{ WEIGHTS.indexOf it.toDouble() }
}
assert checkB( ['10', '11', '13', '1', '2', '2.5'] )
assert checkB( ['11.5', '2', '3'] )
assert checkB( ['12', '2'] )
assert !checkB( ['11', '10', '1', '13', '2', '2.5'] )
assert !checkB( ['1', '12', '3'] )
}
But I am getting error on the line where boolean is mentioned that Description Resource Path Location Type Groovy:Method definition not expected here. Please define the method at an appropriate place or perhaps try using a block/Closure instead.
Does someone know how to convert it to closure to avoid the error