This is an old version, view current version.

5.10 Declaring multiple variables at once

Stan will interpret multiple comma-separated variable names following a single type as declaring multiple new variables. This is available for all variable declarations in all blocks.

Types for multiple declarations

The code:

real x, y;

is equivalent to

real x;
real y;

As a result, all declarations on the same line must be of the same type.

Combining with other features

The ability to declare multiple variables can be combined with assignments whenever a declare-define is valid, as documented in the section introducing compound declarations and definitions :

real x = 3, y = 5.6

Constrained data types can also be declared together, so long as the constraint for each variable is the same:

real<lower=0> x, y;