On Tue, Sep 22, 2009 at 8:07 AM, Justin Johansson
<[email protected]> wrote:
> In a templated class (D1.0) along lines ...
>
> class Foo(T) {
> //..
>  static T bar() { return T.init; }
> //..
> }
>
> Foo!(int).bar() returns 0 and Foo!(char[]).bar() returns nil.
>
> I'd much prefer (at least for my purposes) that (char[]).init returned an 
> empty string rather than effectively a null pointer.  Is there a convenient 
> solution for this, e.g. by specializing just the bar method of class Foo when 
> T is char[], or by some other means?
>
> Maybe this type of question best be asked on D.learn, but I do wonder if an 
> empty string is a more reasonable initializer for char[] .. well maybe not .. 
> I don't know .. I yield to your sensibilities.
>
> Thanks to all.

There's no real difference between an empty string and a null
reference. Both have 0 length.

Reply via email to