突圍foreach循環的,我有這個下面的代碼不能在斯卡拉
> .foreach("${plist}", "newshole") {
> exec(
> http("get the user id")
> .get("${newshole}/jcr:content.1.json")
> .headers(headers_2)
> .check(bodyString.saveAs("Res1"))
> )
> exec(session => {
> var mynewshole = session("Res1").as[String]
> if (!mynewshole.contains("testingInProgress")) {
> println("Doesn't contain: " + mynewshole)
> (http("post the user id")
> .post("${newshole}/jcr:content")
> .headers(headers_2)
> .formParam("testingInProgress", session.userId))
> exec(http("Create print package")
> .post("/bin/cqtg-create-print-package.do")
> .headers(headers_2)
> .formParam("newsholeId", "${plist}")
> .formParam("digitalMasterId", "1adpy8")
> .check(status.is(200)))
>
> }
> session
> })
> }
我想打出來的:
> if (!mynewshole.contains("testingInProgress")) {
> println("Doesn't contain: " + mynewshole)
> (http("post the user id")
> .post("${newshole}/jcr:content")
> .headers(headers_2)
> .formParam("testingInProgress", session.userId))
> exec(http("Create print package")
> .post("/bin/cqtg-create-print-package.do")
> .headers(headers_2)
> .formParam("newsholeId", "${plist}")
> .formParam("digitalMasterId", "1adpy8")
> .check(status.is(200)))
>
> }
> session
基本上我想要從環路時,我的第一個條件滿足爆發。所以我想按照scala教程使用下面的代碼,但不知道在哪裏放置易碎的命令,因爲它給了我錯誤。
> breakable{
> code()
> break;
> }
但不知道往哪裏放it.Any理念????
你可能想考慮**遞歸**,因爲你正在使用Scala :-) – pietro909
基本上我只是想跳出循環,因爲scala donot已經中斷或繼續明確定義。在scala中找到新的位置需要幫助! ! :( – shab