Nordlöw
Nordlöw

Reputation: 12138

Printing Arrays in D

How do I most conveniently print array of numeric values in D? Are there such highlevel overloads or do I have to implement them myself?

In my case I just want to display the contents of data to check the result of.

  double data[] = [ 11,2,3,4,6,1,34 ];
  std.algorithm.sort(data);

Upvotes: 2

Views: 120

Answers (2)

eco
eco

Reputation: 2229

Just import std.stdio and use writeln() on the array.

import std.stdio;

void main()
{
    auto a = [1, 2, 3, 4];
    writeln(a);
}

Upvotes: 7

Hauleth
Hauleth

Reputation: 23586

Have you even tried?

foreach(a; data) writeln(a);

Upvotes: 0

Related Questions