On Friday, 2 April 2021 at 04:38:37 UTC, mw wrote:
On Friday, 2 April 2021 at 04:36:01 UTC, rikki cattermole wrote:
I don't get it, what do you mean by the assertion:


assert(t[9] == '\0');


t == "head-abc-tail"

Just tried this:

https://run.dlang.io/is/SFU5p4

```
import std;
import std.conv : text;


void main()
{
    char[6] s;
    s = "abc";
writeln(s, s.length); // abc6, ok it's the static array's length

    string t = text("head-", s, "-tail");
writeln(t, t.length); // head-abc-tail16, why 16 instead of 13, t's type is string here
    assert(t[9] == '\0');   // ok
    assert(t == "head-abc-tail");  // failed!
}
```

I'm even more puzzled by the last 2 assertions behavior: t is print out as "head-abc-tail".


              • ... H. S. Teoh via Digitalmars-d-learn
              • ... H. S. Teoh via Digitalmars-d-learn
              • ... mw via Digitalmars-d-learn
              • ... Paul Backus via Digitalmars-d-learn
          • Re: w... Computermatronic via Digitalmars-d-learn
            • ... mw via Digitalmars-d-learn
              • ... Computermatronic via Digitalmars-d-learn
              • ... rikki cattermole via Digitalmars-d-learn
              • ... mw via Digitalmars-d-learn
              • ... Berni44 via Digitalmars-d-learn
      • Re: what exac... mw via Digitalmars-d-learn
  • Re: what exactly is st... H. S. Teoh via Digitalmars-d-learn
  • Re: what exactly is st... Виталий Фадеев via Digitalmars-d-learn

Reply via email to