On Tuesday, 3 August 2021 at 12:23:38 UTC, frame wrote:
On Tuesday, 3 August 2021 at 11:55:51 UTC, Paul Backus wrote:

You can't assign a `ref` to a variable; if you try, a copy is created.

What you can do instead is use a pointer:

```d
Unique!myType* rs = &query();
```

Thanks. I feared that. So something like

```
ref T var = ...
```

does not exist (yet)?

No. ```ref``` can only be used as a function/template. or ```foreach``` parameter.
eg:
```d
void main()
{
    ref int i;
}



error: variable `onlineapp.main.i` only parameters or `foreach` declarations can be `ref`
```



Reply via email to