std.string.chomp error
Jonathan M Davis
jmdavisprog at gmail.com
Mon Aug 9 17:35:56 PDT 2010
On Monday, August 09, 2010 17:09:03 simendsjo wrote:
> On 10.08.2010 02:09, Jonathan M Davis wrote:
> > On Monday, August 09, 2010 16:59:07 bearophile wrote:
> >> simendsjo:
> >>> Ahem.. :) Yes, I did miss your answer! How I got fooled by the preview
> >>> pane and never noticed the scrollbar.
> >>
> >> No problem, it happens, don't worry.
> >>
> >>> I cannot see how your other bug report relates to this though.
> >>
> >> My other bug report is about this line in your code:
> >> if (delimiter == null)
> >>
> >> I don't like it :-)
> >>
> >> Bye,
> >> bearophile
> >
> > Why, because it should be
> >
> > if(delimiter is null)
> >
> >
> > or just
> >
> > if(!delimiter)
> >
> >
> > - Jonathan M Davis
>
> Hehe.. You're a bit beyond my D level right now. At least I now know
> null == false and you can do reference is null :)
IIRC, you're not really supposed to do "delim == null" but rather us "delim is
null" or shorten to to just "!delim". Why, I don't recall off the top of my head,
but it might be because "delim == null" would be calling Object.opEquals(), and
there's no need for that function call (though fortunately "delim == null"
translates to Object.opEquals(delim, null) rather than delim.opEquals(null)
which avoids issues where the lhs is null and causes it to go boom).
In either case, for null checks, I'd suggest either just using the reference by
itself or to explictly use "is null" if you want the extra clarity.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list