No "break" for "while"?

1,292 views
Skip to first unread message

Freewind

unread,
Jun 23, 2012, 2:10:04 AM6/23/12
to xtend...@googlegroups.com
See this code:

def static void main(String[] args) {
var i = 0
while(true) {
i = i+1
if(i>10) break
}
}

There is compilation error on "break", it seems xtend doesn't support "break'. What should I do now?

For this simple example, I can change it to:

     while(i<=10) { i = i+1 }

But if the logic is complex, the "break" is very useful.

Sven Efftinge

unread,
Jun 24, 2012, 2:05:18 AM6/24/12
to xtend...@googlegroups.com
'break' and 'continue' are not supported.

digulla

unread,
Jun 25, 2012, 3:50:51 AM6/25/12
to xtend...@googlegroups.com
Instead of 'break', move the loop body into a closure or new method and use 'return'

Freewind

unread,
Jun 25, 2012, 11:34:16 AM6/25/12
to xtend...@googlegroups.com
Will them in plan?
Reply all
Reply to author
Forward
0 new messages