What is the difference between a[x][y] and a[x,y]?

Robert M. Münch robert.muench at saphirion.com
Tue Jan 7 17:38:59 UTC 2020


I read all the docs but I'm not toally sure. Is it that [x][y] is a 2D 
array-index, where as [x,y] is a slice?

But the example in docs for opIndexAssign uses the [x,y] syntax, which 
is confusing:

```
struct A
{
    int opIndexAssign(int value, size_t i1, size_t i2);
}

void test()
{
    A a;
    a[i,3] = 7;  // same as a.opIndexAssign(7,i,3);
}
```

And what is the difference between opIndexAssign and opIndexOpAssign?

Background: I have a class with a 2D array of some other class objects 
as memember and want to be able to use it as LHS and RHS.

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list