Values in D Programming Language

D has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.

import std.stdio;

void main()
{
    // Strings, which can be concatenated with ~
    writeln("d" ~ "lang");

    // Integers and floats
    writeln("1+1 = ", 1 + 1);
    writeln("7.0/3.0 = ", 7.0 / 3.0);

    // Booleans, with boolean operators as you'd expect
    writeln(true && false);
    writeln(true || false);
    writeln(!true);
}

To run the program, save it as values.d and use the D compiler:

$ dmd values.d
$ ./values
dlang
1+1 = 2
7.0/3.0 = 2.33333
false
true
false

In this D program:

  1. We import the std.stdio module, which provides input/output functionality.

  2. The main function is the entry point of the program.

  3. String concatenation in D uses the ~ operator instead of +.

  4. The writeln function is used for printing to the console, similar to fmt.Println in the original example.

  5. Integer and float operations work similarly to other languages.

  6. Boolean operations are the same as in many other programming languages.

D provides a similar set of basic types and operations as other modern programming languages, making it easy to work with various kinds of data.