Hello!
I was attempting project euler problem 22 and seeing something
weird going on with the array function in std.array.
I made the following code to demonstrate.

Given names.txt:
------------------
"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH"
------------------

and code:
------------------
import std.array,std.stdio;

void main()
{
      { // Correct
          auto names = File("names.txt","r")
              .byLine!(char,char)(KeepTerminator.no,',');

          foreach(char[] name; names ){ writeln( name ); }
      }
      { // Converting to "array" borks the thing
          auto names = File("names.txt","r")
              .byLine!(char,char)(KeepTerminator.no,',')
              .array;

          foreach( char[] name; names){ writeln( name ); }
      }
}
------------------

I get the following output:
------------------
➜ euler rdmd ./stdArrayBug.d
"MARY"
"PATRICIA"
"LINDA"
"BARBARA"
"ELIZABETH"


"ELIZA
"ELIZABETH
"ELIZAB
"ELIZABET
"ELIZABETH"
------------------

Am I using array incorrectly?
I searched bugzilla and didn't see anything pertaining to this
issue.
Should I file a bug?

DMD64 D Compiler v2.066.1
Ubuntu Linux

Thanks!

Reply via email to