On Tuesday, 15 April 2014 at 16:02:33 UTC, Steven Schveighoffer
wrote:
On Tue, 15 Apr 2014 11:59:31 -0400, Steven Schveighoffer
<schvei...@yahoo.com> wrote:
On the left hand side, the [] operator is special *for arrays*
in that it denotes you want to do an element-wise copy. On the
right hand side, this is not the case, [] is simply an
operator. It's a no-op if the rhs is an array, since [] just
gets the array again.
Sorry, I had this wrong. The [] on the left hand side is
actually part of the []= operator. But on the right hand side,
it simply is a [] operator, not tied to the =. I erroneously
thought the arr[] = ... syntax was special for arrays, but I
forgot that it's simply another operator.
My opinion is still the same.
-Steve
Maybe we should require the []= operator to be written exactly
like this.
t[] = v;
t.opSlice.opAssign(v) or t.opSliceAssign(v)? I bet most people
(me included) will get this wrong 50% of the time.