|
Return from the Closure: msg#00089lang.groovy.user
the code: class test { lt = ['a','b','c'] find1(value){ lt.each ({ if (it == value){ return "1:${it}" } }) return '1:not found!' } find2(value){ for (item in lt){ if (item == value){ return "2:${item}" } } return '2:not found!' } static void main(argv){ ins = new test() println ins.find1('a') println ins.find2('a') } } result: 1:not found! 2:a I find when to be return from the Closure, it actually break the loop, and can't return from the method. I think this not like usual habit, please provide the opinion thanks. <renlixin-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx>
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: GPath, and Builder synergy, Incze Lajos |
|---|---|
| Next by Date: | RE: Return from the Closure, Laforge Guillaume |
| Previous by Thread: | xml with namespaces, Valenta, Jakub \(GE Healthcare\) |
| Next by Thread: | RE: Return from the Closure, Laforge Guillaume |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |