why foreach() don't use 'auto'?
Dicebot
public at dicebot.lv
Thu Mar 27 03:03:03 PDT 2014
On Thursday, 27 March 2014 at 09:19:20 UTC, ketmar wrote:
> why foreach() using the current syntax instead of clearer one:
> foreach (auto v; smth)?
>
> i think that adding 'auto' will make foreach() less confusing,
> as
> it clearly points that 'v' is a local variable for foreach()
> scope. and i think that it will be in line with other forms such
> as foreach(immutable v; smth), etc.
>
> current foreach() syntax (without auto) still sometimes
> confusing
> me and forcing to believe that i should either put 'auto' inside
> foreach() or somehow declare 'v' before foreach().
You can use `auto` in foreach, as well as any explicit type. It
can be omitted because it is unambiguous.
More information about the Digitalmars-d
mailing list