File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -419,3 +419,39 @@ var foo = exists bar
419419// Variable foo exists, so true
420420var bar = exists foo
421421```
422+
423+ ## Labeled Statements and Expressions
424+ The following statements and expressions can be labeled.
425+ - [ ` for ` ] ( #for )
426+ - [ ` each ` ] ( #each )
427+ - [ ` while ` ] ( #while )
428+ - [ ` do-while ` ] ( #do-while )
429+ - [ ` loop ` ] ( #loop )
430+ - [ ` if ` ] ( #if )
431+ - [ ` eval ` ] ( #eval )
432+ - [ ` match ` ] ( #match )
433+
434+ You can exit outer blocks using labeled ` break ` and ` continue ` statements in nested blocks.
435+ ``` aiscript playground
436+ #outer: for let x, 3 {
437+ for let y, 2 {
438+ if (x == 1 && y == 1) {
439+ continue #outer
440+ }
441+ <: [x, y]
442+ }
443+ }
444+ ```
445+
446+ A ` break ` statement associated with ` eval ` , ` if ` , or ` match ` can include a value.
447+ ``` aiscript playground
448+ <: #label1: eval {
449+ break #label1
450+ 1
451+ } // => null
452+
453+ <: #label2: eval {
454+ break #label2 2
455+ 3
456+ } // => 2
457+ ```
Original file line number Diff line number Diff line change @@ -419,3 +419,39 @@ var foo = exists bar
419419// 変数fooが存在するためtrue
420420var bar = exists foo
421421```
422+
423+ ## ラベル構文
424+ 以下の文や式にラベルを付与することができます。
425+ - [ ` for ` ] ( #for )
426+ - [ ` each ` ] ( #each )
427+ - [ ` while ` ] ( #while )
428+ - [ ` do-while ` ] ( #do-while )
429+ - [ ` loop ` ] ( #loop )
430+ - [ ` if ` ] ( #if )
431+ - [ ` eval ` ] ( #eval )
432+ - [ ` match ` ] ( #match )
433+
434+ ネストしたブロック内でラベルを付与した` break ` 文や` continue ` 文を使用することで外側のブロックから脱出することができます。
435+ ``` aiscript playground
436+ #outer: for let x, 3 {
437+ for let y, 2 {
438+ if (x == 1 && y == 1) {
439+ continue #outer
440+ }
441+ <: [x, y]
442+ }
443+ }
444+ ```
445+
446+ ` eval ` または` if ` , ` match ` に対応するbreak文には値を指定することができます。
447+ ``` aiscript playground
448+ <: #label1: eval {
449+ break #label1
450+ 1
451+ } // => null
452+
453+ <: #label2: eval {
454+ break #label2 2
455+ 3
456+ } // => 2
457+ ```
You can’t perform that action at this time.
0 commit comments