Static foreach internal variable

Basile B. b2.temp at gmx.com
Thu Aug 30 08:39:15 UTC 2018


On Thursday, 30 August 2018 at 08:19:47 UTC, Andrey wrote:
> Hello,
> is it possible to declare an internal variable in "static 
> foreach" and on each iteration assign something to it?
> Example:
>>static foreach(arg; SomeAliasSeq)
>>{
>>    internal = arg[0].converted;    // a shortcut for 
>> expression "arg[0].converted"
>>
>>    static if(internal.length == 0) { ... }
>>    else static if(internal.isNull) { ... }
>>    else { ... }
>>}

Add a scope :

static foreach(arg; SomeAliasSeq)
{{
}}

And this should work without complaint about "internal" already 
existing.


More information about the Digitalmars-d-learn mailing list