tuple can write [],but can't read []
FrankLike via Digitalmars-d
digitalmars-d at puremagic.com
Tue Apr 29 02:23:01 PDT 2014
Hi,erveryone,
type Tuple!(int,int,int,string) can write[],but can't read[];
module main;
import std.stdio,std.typecons,std.conv;
void main(string[] argv)
{
alias Tuple!(int,int,string) tuple2;
alias Tuple!(int,int,string)[10] tupleS2;
void bbx(tupleS2 x)
{
foreach(v;x)
{
writeln(v);
foreach(k;v)
writeln(k);
}
}
tupleS2 xy2;
foreach(i,v;xy2)
{
xy2[i] = tuple2(1,-1,"xy2 :"~i.to!string);
}
xy2[1][0]=100; // can write
bbx(xy2);
for(int i=0;i<3;i++)
{
writeln(xy2[0][i]); // can't read
}
}
-------------------code end----------------------
if use the 'for(int i=0;i<3;i++)' ,then error.
Error: no [] operator overload for type Tuple!(int, int, int,
int, int, int, int, int, int, int, int, string)
Thank you.
Frank
More information about the Digitalmars-d
mailing list