immutable are type qualifiers. This means that, when applied to any type, they actually create a new type. For example, the following equivalent declarations all create a type that is called
const int x = 10; const(int) y = 11; const z = 12;
In the declaration of
z, the compiler will infer the type. For a basic type such as
int, it makes no difference which syntax is used. However, we'll see shortly that things can be a bit confusing with derived data types, so you may want to get into the habit of using the syntax in the second line when you need to explicitly specify the type. In the rest of this section, we're going to explore the contracts of both
immutable, then take ...