std.string.chomp error

Jonathan M Davis jmdavisprog at gmail.com
Mon Aug 9 18:34:16 PDT 2010


On Monday, August 09, 2010 18:12:11 simendsjo wrote:
> On 10.08.2010 03:08, bearophile wrote:
> > Jonathan M Davis:
> >> Why, because it should be
> >> 
> >> if(delimiter is null)
> >> 
> >> 
> >> or just
> >> 
> >> if(!delimiter)
> > 
> > if (delimiter.length == 0)
> > Or
> > if (!delimiter.length)
> > 
> > Bye,
> > bearophile
> 
> Isn't that very different things? You cannot use .length if delimiter is
> null.

If that's what you're looking for, then the proper thing to do would be to 
import std.array and do this

if(delimiter.empty)

It wille handle both null and length == 0 cases. Not to mention, it's much more 
range-y that way.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list