Skip to content

CompoundExpression

CompoundExpression[e1, e2, ...] evaluates each expression in order and returns the result of the last one.

Attributes[CompoundExpression] := {HoldAll, Protected, ReadProtected}

Simple examples

The result of the first expression is not included in the output, but the result of the second is:

In[1]:= CompoundExpression[a = 5, a + 2*-1]
Out[1]= 3
Including a trailing semicolon causes the expression to return Null:
In[2]:= CompoundExpression[a = 5, a + 2*-1, Null]
Out[2]= Null