Named Blocks

From Sputnik Wiki
Revision as of 13:21, 20 January 2015 by UberFoX (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox