Elegant way for do … while in groovy

前端 未结 6 835
Happy的楠姐
Happy的楠姐 2020-12-29 00:44

How to do code something like this in groovy?

do {

  x.doIt()

} while (!x.isFinished())

Because there is no do ... w

6条回答
  •  爱一瞬间的悲伤
    2020-12-29 01:23

    You can use a condition variable with the regular while loop:

    def keepGoing = true
    while( keepGoing ){
        doSomething()
        keepGoing = ... // evaluate the loop condition here
    }
    

提交回复
热议问题