On Tue, 11 Feb 2014 19:08:18 -0000, Jesse Phillips <jesse.k.phillip...@gmail.com> wrote:

On Tuesday, 11 February 2014 at 13:00:19 UTC, Regan Heath wrote:
import std.stdio;

struct S1 {
   private int[] elements = [9,8,7];
   int opApply (int delegate (ref uint, ref int) block) {
       foreach (uint i, int n ; this.elements)
           block(i, n);
       return 0;
   }
}

void main()
{
        S1 range;

S1 is not a range. But this is a correct response to "Is foreach(i, val; aggregate) even defined if aggr is not an array or associated array?"

True, but then I had missed the fact that there are two distinct mechanisms (opApply/range) in play here.

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to