Fork me on GitHub

Block Expressions

The block expression consists of a sequence of expressions.

##1. General Syntax

A block expression is surrounded by curly braces. The expressions in a block can be terminated by an optional semicolon.

{
	<sequence of expressions>
}

##2. Type and Value of a Block Expression

The value of the last expression in the block is returned as the value of the complete block.

The type of a block is the returned type (i.e., of the last expression). Empty blocks return null and have the type Object.

In the following example, the block type is String because the last expressions in all the possible execution paths are all of type String.

{
	var x = greeting
	if (x == "Hello") {
		x + " World!" 
	} else {
		x
	}
}

##3. Acknowledgements

This documentation is inspired by the documentations from the Xtext and Xtend projects.

##4. Legal Notice

Copyright © 2014-2019 the original authors or authors.

Licensed under the Apache License, Version 2.0; you may not use this file except in compliance with the License. You may obtain a copy of the License.

You are free to reproduce the content of this page on copyleft websites such as Wikipedia.

Generated with the translator io.sarl.maven.docs.generator 0.10.0.