Array concat quiz

bearophile bearophileHUGS at lycos.com
Fri Dec 16 17:43:17 PST 2011


A small quiz. This Python2 code:

m1 = [["A'", "B'"]]
print m1
m2 = m1 + [[]]
print m2


Prints:

[["A'", "B'"]]
[["A'", "B'"], []]


What does this D2 program print?

import std.stdio;
void main() {
    string[][] m1 = [["A'", "B'"]];
    writeln(m1);
    string[][] m2 = m1 ~ [[]];
    writeln(m2);
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list