Verbosity in D

pascal111 judas.the.messiah.111 at gmail.com
Mon Aug 8 00:15:48 UTC 2022


On Sunday, 7 August 2022 at 23:44:26 UTC, Emanuele Torre wrote:
> On Sunday, 7 August 2022 at 23:31:45 UTC, pascal111 wrote:
>> On Sunday, 7 August 2022 at 22:16:55 UTC, Emanuele Torre wrote:
>>> [...]
>>
>> It seems complex, I didn't get it yet, I wished I didn't ask 
>> about it :)
>
> It's really trivial.
> `auto [x, y] = getpoint();` is equivalent to
> ```C++
> auto _p = getpoint();
> auto x = _p.x /* first element of the struct */;
> auto y = _p.y /* second element of the struct */;`
> ```
> Also works with arrays.
> ```C++
> int[] arr = { 10, 12, 14 };
> const auto [x, y, z] = arr;
> /* x=10 y=12 z=14 */
> ```
> A lot of programming languages have this.

Really, I'm not sure I'm understanding this syntax `auto [x, y] = 
getpoint();`, if you have the name of term of it in D or an 
explaining link.


More information about the Digitalmars-d-learn mailing list