groovysoapuigroovyscriptengine

`null` returned in groovy counter using while (soapui groovyscript)


The below code returns a null at the end of the list, which i'm sure is going to give me issues later on. Does anyone know why? I'm sure I'm not understanding something about how this language works :(

def loop(){
    c=51
    while (c!=0){
        log.info c
        c--
    }
}
log.info loop()
...................................
Mon Oct 08 11:46:06 CAT 2018:INFO:4
Mon Oct 08 11:46:06 CAT 2018:INFO:3
Mon Oct 08 11:46:06 CAT 2018:INFO:2
Mon Oct 08 11:46:06 CAT 2018:INFO:1
Mon Oct 08 11:46:06 CAT 2018:INFO:null

Solution

  • As per the code look like , you should have 'log.info c' before this 'c--', could you please provide full groovy file ?

    def loop(){
        c=51
        while (c!=0){
            log.info c
            c--        
        }
    }