struct initializer
Paul Backus
snarwin at gmail.com
Fri Dec 1 14:53:16 UTC 2023
On Friday, 1 December 2023 at 13:02:06 UTC, Dom DiSc wrote:
> ```d
> S Fun(){ return { 5, 2 }; }
> ```
>
> This IS an initialization and the type is known. Requiring the
> repetition of the type is also here annoying.
Technically you don't *have* to repeat the type. You can write
the return type as `auto`:
```d
auto fun() { return S(5, 2); }
```
Or you can use `typeof(return)`:
```d
SomeReallyLongReturnType fun()
{
return typeof(return)(5, 2);
}
```
More information about the Digitalmars-d-learn
mailing list