Array is already defined
Vino
vino.bheeman at hotmail.com
Fri Jan 5 15:56:30 UTC 2018
On Friday, 5 January 2018 at 15:28:58 UTC, Jonathan M Davis wrote:
> On Friday, January 05, 2018 15:22:49 Vino via
> Digitalmars-d-learn wrote:
>> Hi All,
>>
>> Request your help on how to unset or delete an array, in the
>> below example, we get an error "Common is already defined".
>>
>> Auto fn1 () {
>> Array!string Text;
>> Array!string Number;
>> return tuple(Text, Number);
>> }
>>
>> Void main () {
>> static foreach(i; 0 .. 2) {
>> typeof(fn1()[i]) Common;
>> writeln(Common[]);
>> Common.delete or Common.Unset // Something similar like this
>> }
>>
>> From,
>> Vino.B
>
> static foreach does not create a new scope (if it did, it
> wouldn't work very well at module or class/struct scope). If
> you declare any variables inside a static foreach, give it an
> extra set of braces.
>
> - Jonathan m Davis
Hi Jonathan,
Sorry , not able to get you, can you please point our as to
where we need to added the braces in the below example.
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[]);
}
From,
Vino.B
More information about the Digitalmars-d-learn
mailing list