D (The Programming Language)/d2/Types, Continued

=Lesson 4: Types, Continued= In this lesson, you will see all the other types. Many of these types will be familiar, but be aware that there are many differences between C and D in their built-in types.

Assertion
Using  allows you to check if a certain expression is true or not. means is equal to (do not confuse this with, which is for assigning variables). The checking is done at runtime, and if whatever is inside the parentheses evaluates to false, then an Assertion Error will happen and the program will terminate.

Properties and Default Initializers
Types have default initializers. That means, if they are declared but not assigned any value, they will be equal to something by default. Properties can be queried from any type or object. When a property of a type or object is queried, a dot goes between the property name and the identifier. The  property of any type contains the value that objects of such a type are initialized to by default. For numeral types, you can find the min and max values with their respective properties:   and. You can also find the size of a type in memory:. If you want to declare but don't want to initialize something, you can do this: Then, i is uninitialized; its value is undefined garbage.

A Bit of D's Lexical Grammar
D allows you to write numbers in a few useful bases and forms. So, if you wanted to add the hexadecimal number of A4 to one million three hundred thirteen thousand six hundred thirty-seven and the binary number of 1011010101, you can write this: Note that underscores in the middle of numbers are completely ignored. They are 100% optional and are useful for formatting long numbers.

Tips

 * You may look through this reference for more information about D's lexical grammar. Soon a lesson will be written that contains up-to-date information on the subject.