Sunday, 15 September 2013

Loop counter in D language -


In this tutorial (), it is commented that if foreach support range is provided by member functions , Then a loop counter can only be obtained by calculating with the std.range module: with the example.

  import std.range; // ... foreach (i, element; number range (42, 47).) {Writefln ("% s:% s", i, element); }  

I tried to use this example to check notation , but I got the error error: a property of 'number range' For 'Multiplication' / code>. What could be wrong? Import std.stdio; Import std.range; Void main () {foreach (i, element; iota (42, 47). Estimation) {writefln ("% s:% s", i, element); }}

enumerate released after 2.066 Was there. It will be available in 2.067.

BTW, you may or may not be aware of it, but you can use std.range.iota instead of number range.


No comments:

Post a Comment