Cannot implicitly convert expression of type const(string[]) to string[]

Andrey saasecondbox at yandex.ru
Fri Jan 8 20:43:37 UTC 2021


Hello,

> struct Value
> {
>     int value;
>     string data;
>     string[] text;
> }
> 
> void test(const ref Value value)
> {
>     Value other = void;
>     other.text = value.text;
> }
> 
> void main()
> {
>     Value row;
>     row.value = 10;
>     row.data = "ttttggg";
> 
>     test(row);
> }

I want to pass variable "row" inside function "test" as a read 
only parameter.
Inside I create another variable and try to assign field "text".
On that line I get:
> Error: cannot implicitly convert expression value.text of type 
> const(string[]) to string[].

1. How to assign correctly (and without dup/ugly cast())?
2. Or how to pass "row" correctly?


More information about the Digitalmars-d-learn mailing list