Re: Initializing an associative array of struct

2020-06-14 Thread Denis via Digitalmars-d-learn
On Sunday, 14 June 2020 at 15:44:04 UTC, Ali Çehreli wrote: On 6/14/20 7:43 AM, Denis wrote:> @Kagamin: > > On Sunday, 14 June 2020 at 07:16:18 UTC, Kagamin wrote: >> parameters[param]=Parameter(); > > I did not realize that you can use a type on the RHS of an assignment, Note that it's not

Re: Initializing an associative array of struct

2020-06-14 Thread Ali Çehreli via Digitalmars-d-learn
On 6/14/20 7:43 AM, Denis wrote:> @Kagamin: > > On Sunday, 14 June 2020 at 07:16:18 UTC, Kagamin wrote: >> parameters[param]=Parameter(); > > I did not realize that you can use a type on the RHS of an assignment, Note that it's not just the type but with parenthesis after it. For example, Foo()

Re: Initializing an associative array of struct

2020-06-14 Thread Denis via Digitalmars-d-learn
@Kagamin: On Sunday, 14 June 2020 at 07:16:18 UTC, Kagamin wrote: parameters[param]=Parameter(); I did not realize that you can use a type on the RHS of an assignment, but it is clear and succinct. This syntax will be very useful going forward -- thank you. @Stanislav B: On Sunday, 14

Re: Initializing an associative array of struct

2020-06-14 Thread Stanislav Blinov via Digitalmars-d-learn
On Sunday, 14 June 2020 at 04:36:09 UTC, Denis wrote: Note also that the defaults for id and value are fine... I would welcome a suggestion for how to initialize the keys of parameters. As there will be a couple dozen of the param string keys, a more succinct method would be preferable over

Re: Initializing an associative array of struct

2020-06-14 Thread Kagamin via Digitalmars-d-learn
string param="aa"; parameters[param]=Parameter(); in id=parameters[param].id;

Re: Initializing an associative array of struct

2020-06-14 Thread Kagamin via Digitalmars-d-learn
that's int id=parameters[param].id;

Initializing an associative array of struct

2020-06-13 Thread Denis via Digitalmars-d-learn
Hi, I'm trying to combine a couple of general types (associative array, struct) in a compound data structure, but without success. Here is what I'm trying to achieve: "param" is a string variable "parameters[param].id" is an integer value "parameters[param].value" is a string