On 03/24/2016 10:24 AM, data pulverizer wrote: > I have been playing with the matrix example given at the end of chapter > 78 of Ali Çehreli's
For reference, it's "Multi-dimensional operator overloading example" here: http://ddili.org/ders/d.en/templates_more.html >having problems with overloading the opAssign operator. > > rows is a private int[][] in a Matrix struct. > > I have added the following ... > > Matrix opAssign(int[][] arr) > { > this.rows = arr; > // rows = arr // does not work either ... > return this; > } > > However this does not work (no error occurs, it just doesn't do > anything) How are you testing it? The following worked for me: 1) Added that opAssign() to the struct. (Verified that it gets called.) 2) Tested with the following code: auto m2 = Matrix(); auto rows = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; m2 = rows; writeln(m2); (I've tested with a dynamically generated 'rows' as well.) Ali