Named Blocks
From Sputnik Wiki
Contents |
Name { }
Description
A named block is similar to your normal { } block but since it has a name you can specifically *break* from that thing no matter where you are inside the block.
Name { statements ... }
Parameters
Name
The name to give this named block we will need the name later in the break statement.
Block
The block of code to execute.
Remarks
Name { } statements may be nested.
Example
Break from first one
say "Begin"; hehe { say "Toy"; test { say "Cat"; { say "Dog"; if(1 == 1) { break 'hehe'; } say "Fox"; } say "Cow"; } say "Mat"; } say "End"; // Prints // Begin // Toy // Cat // Dog // End
Break from second one
say "Begin"; hehe { say "Toy"; test { say "Cat"; { say "Dog"; if(1 == 1) { break 'test'; } say "Fox"; } say "Cow"; } say "Mat"; } say "End"; // Prints // Begin // Toy // Cat // Dog // Mat // End