Enhancing foreach
Ary Borenszweig
ary at esperanto.org.ar
Tue Jan 15 10:41:50 PST 2013
On Thursday, 10 January 2013 at 17:36:15 UTC, Raphaël Jakse wrote:
> Le 10/01/2013 10:23, monarch_dodra a écrit :
>> On Thursday, 10 January 2013 at 03:29:21 UTC, Peter Summerland
>> wrote:
>>
>> The only thing I'd want to be able to do is:
>> //----
>> foreach ( ; 0 .. 5)
>> {
>> writeln("hello");
>> }
>> //----
>>
>> If I don't need a named variable, why force me to define a
>> symbol?
>> http://d.puremagic.com/issues/show_bug.cgi?id=9009
>>
>> I know I could just use "i" and move on, but when code starts
>> getting
>> complex, and you already have i, j, k, ii, dummy etc..., it
>> can make a
>> difference.
>
>
> What about :
>
> foreach (0 .. 5)
> {
> writeln("hello");
> }
>
> ?
What about:
5 {
writeln("hello");
}
It could even work with floats!
1.5 {
writeln("nice");
}
prints:
nice
ni
More information about the Digitalmars-d-learn
mailing list