char[] annoyance...
Derek Parnell
derek at psych.ward
Mon Apr 10 01:51:00 PDT 2006
On Mon, 10 Apr 2006 17:54:25 +1000, S. Chancellor
<dnewsgr at mephit.kicks-ass.org> wrote:
> Erps, I should skim your post better. Yeah that's a problem, you can
> fix it without the other if though.
>
> for(int i = 0; i + 2 < line.length; i++) {
>
>
> Or am I still missing something? Hehe.
No, that is fine and along the same lines as the original code. As is
for(int i = 0; i < (cast(int)line.length)-2; i++) {
however I still prefer telling the code reader what I'm doing etc... in
clear, simple code. Although your code will work, it just isn't as clear
at first glance as
if (line.length >= 2)
{
...
}
but of course an even better way (IMHO) ...
int posn = std.string.find(line, "||");
if (posn >= 0)
{
// etc ....
}
--
Derek Parnell
Melbourne, Australia
More information about the Digitalmars-d
mailing list