Array is already defined

Vino vino.bheeman at hotmail.com
Fri Jan 5 17:22:59 UTC 2018


On Friday, 5 January 2018 at 16:55:50 UTC, Steven Schveighoffer 
wrote:
> On 1/5/18 11:39 AM, Vino wrote:
>> 
>> Hi Steve,
>> 
>>   if we add the braces we are getting the Error: undefined 
>> identifier Datacol
>> 
>> void main () {
>> Array!int Keycol;
>> static foreach(i; 0 .. 3) {
>>      {
>>          typeof(read()[i]) Datacol;
>>          Datacol.insertBack(sort(read[i].dup[]).uniq);
>>          foreach(k; read[i]) { 
>> Keycol.insertBack(Datacol[].countUntil(k));}
>>      }
>> }
>>      writeln (Datacol[], Keycol[]);
>> }
>
> That's because writeln is outside the loop that defines Datacol.
>
> Without knowing what you are trying to do, it's hard to further 
> help.
>
> -Steve

Hi Steve,

  Thank you very much, was able to resolve the issue after adding 
the writeln within the braces, I am trying to implement a data 
dictionary compressing using D, and had 2 issue and this is one 
of the issue, and the other issue is detailed in the post "Error: 
variable i cannot be read at compile time", which contains the 
details of this program, if possible can you please help on on 
the other issue in the post "Error: variable i cannot be read at 
compile time".

From,
Vino.B




More information about the Digitalmars-d-learn mailing list