writefln on interface array

Steven Schveighoffer schveiguy at yahoo.com
Thu Apr 8 04:53:00 PDT 2010


On Wed, 07 Apr 2010 07:13:07 -0400, strtr <strtr at spam.com> wrote:

> Is it possible to have this output [null,"1"] in stead of Error:  
> std.format formatArg?
>
> interface I{}
> class C:I{
> int index;
> char[] toString(){ return toString(index) }
> }
>
> I[2] two_i;
> I[1] = new C();
> writefln(two_i);
>
>
>
> Would be handy for debugging ;)
>

Don't think this is exactly what you are looking for, but have you tried  
writeln?  writefln requires the first argument to be a string, it didn't  
used to, but it was determined that the resulting behavior when you want  
to just print a string is too confusing.

-Steve


More information about the Digitalmars-d-learn mailing list