Blocks
Sometimes it is necessary to execute a series of
expressions where the expressions are executed for
their side-effects. For example, you may want to print
some things before returning a value. The Block
expressions executes a sequence of expressions, discarding
the result values of each expression except the last, which
becomes the return value of the block.
This example of a block is not very useful, but shows how it allows a sequence of expressions. The value of the overall block expression is just the value of the last expression, the int constant 20:
new Block(new Expression[]{
new ByteConstant((byte) 3),
new IntConstant(5),
new StringConstant("foo"),
new ShortConstant((short) 7),
new IntConstant(20)
})