Automatic Type Conversions

Let’s learn about automatic type conversions and integer promotions.

Variables must be compatible with the expressions that they take part in. As it has probably been obvious from the programs that we have seen so far, D is a statically typed language, meaning that the compatibility of types is validated at compile time.

All of the expressions that we have written so far always had compatible types because otherwise the code would be rejected by the compiler. The following is an example of code that has incompatible types:

svg viewer

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy