Named Blocks

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
UberFoX (Talk | contribs)
(Created page with "= 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 a...")
Newer edit →

Revision as of 13:21, 20 January 2015

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