https://issues.dlang.org/show_bug.cgi?id=16305

Lodovico Giaretta <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from Lodovico Giaretta <[email protected]> ---
(In reply to Danila Letunovskiy from comment #0)
> import std.stdio;
> 
> void main(){
>       int[] m = [1,2,3];
> 
>       m = m ~ 4 ~ 5; // ok
> 
>       m ~= 4 ~ 5; // not work
> }

It works as intended. binary ops have precedence over assignment ops, so your
last expression is equivalent to

 m ~= (4 ~ 5);

And (4 ~ 5) does not make sense, because ~ is defined when at least one operand
is an array.

What you want is one of these two (probably the first):

 (m ~= 4) ~= 5;
 m ~= [4] ~ 5;

--

Reply via email to