On Sun, 14 Sep 2014 00:34:54 +0000
WhatMeWorry via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
wrote:

> So is one form (Empty strings versus null strings) considered 
> better than the other?  Or does it depend on the context?
one is better than another in the sense that blue is better than green
(or vice versa). ;-)

don't count on that trailing zero, and don't count on empty string
being null or points to somewhere. `.length` is all that matters.

> Also as an aside (and I'm not trying to be flippant here), aren't 
> all strings literals?  I mean, can someone give me an example of 
> a string non-literal?

  string foo () {
    import std.conv;
    string s;
    foreach (i; 0..10) s ~= to!string(i);
    return s;
  }

this function returns string, but that string is in no way built
from literal.

note that it's string *contents* are immutable, not the whole string
structure. there is a difference between `immutable(char[])` and
`immutable(char)[]`. that is why you can use `~=` on strings.

Attachment: signature.asc
Description: PGP signature

Reply via email to