Groups
Conversations
All groups and messages
Send feedback to Google
Help
Training
Sign in
Groups
한국 Groovy & Grails 사용자 그룹
Conversations
About
[질문] 클로져에서 빠져나오는 방법은?
11 views
Skip to first unread message
JunBok Park
unread,
Mar 6, 2012, 8:02:33 PM
3/6/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to KG...@googlegroups.com
반복문으로 사용되는 클로져에서 빠져나오는 방법은 어떻게 될까요?
일반적인 루프문에서는 break 빠져나올 수 있는데요. 클로져에서는 어떻게 해야될 지?
예를 들어서 아래와 같이 하면 당연히 에러가 발생하는데요. 해법이 어떻게 될까요?
10.times { item ->
println item
if (item == 7) break
}
JunBok Park
unread,
Mar 6, 2012, 8:11:51 PM
3/6/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to KG...@googlegroups.com
자답입니다. 검색을 해보니, 나오네요. ^^
다음처럼 Exception 을 이용하면 되긴 하네요.
try {
10.times { item ->
println item
if(item == 6) throw new Exception("break")
}
} catch (e) {}
println "Hi.."
Reply all
Reply to author
Forward
0 new messages