Ternary if and ~ does not work quite well
deed via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 12 10:22:36 PDT 2015
On Monday, 12 October 2015 at 15:39:15 UTC, TheFlyingFiddle wrote:
> How does this compile?
{
string str = "hello";
foreach (n; [32, 119, 111, 114, 108, 100, 33]) str ~= n;
import std.stdio : writeln;
str.writeln; // prints "hello world!"
writeln(true == 1); // true
writeln(false == 0); // true
string str2 = str.dup;
str ~= 0;
str2 ~= false;
writeln(str == str2); // true
str ~= 1;
str2 ~= true;
writeln(str == str2); // true
}
More information about the Digitalmars-d-learn
mailing list