On 08/07/2015 02:05 AM, Reflexive wrote:

> class sabot{
>      carte[] sabotarray ;
>
>      this(){
>          int i ;
>          for (i=1 ; i<=52 ; i++){
>              carte tempcarte ;
>              tempcarte.id = i ;
>              sabotarray[] ~= tempcarte  ; // line 17

dmd 2.068 gives a better message:

Error: slice expression this.sabotarray[] is not a modifiable lvalue

Just drop the []:

            sabotarray ~= tempcarte;

After all, the symbol 'sabotarray' represents the array and you want to append to it. On the other hand, sabotarray[] is a temporary slice, which happens to be an rvalue (read: not modifiable). You don't want to append to that temporary.

Ali

Reply via email to