non-aa-initializer?

Salih Dincer salihdb at hotmail.com
Fri Dec 2 19:55:54 UTC 2022


On Friday, 2 December 2022 at 19:36:10 UTC, Salih Dincer wrote:
> This looks like the nested objects I use in JSON ...

Here's what I'm talking about:

```d
import std.json;
import std.stdio;

void main()
{
   alias nd = JSONValue;
   nd root;
   string[] A, I;

   A = ["a", "â", "A", "Â"];
   I = ["ı", "î", "I", "Î"];

   nd[string] let = [
     "Lower" : nd([ "a letter" : nd( A[0..2] ),
                    "ı letter" : nd( I[0..2] )
     ]),
     "Upper" : nd([ "A letter" : nd( A[2..$] ),
                    "I letter" : nd( I[2..$] )
     ])
   ];

   root.object = ["Turkish" : nd( let )];
   root.toJSON(true).writeln;
} /*
{
     "Turkish": {
         "Lower": {
             "a letter": [
                 "a",
                 "â"
             ],
             "ı letter": [
                 "ı",
                 "î"
             ]
         },
         "Upper": {
             "A letter": [
                 "A",
                 "Â"
             ],
             "I letter": [
                 "I",
                 "Î"
             ]
         }
     }
}
*/

```

So you need to init nested AA at different times. If you want the 
compiler to do this in one line, we have to use parentheses.

SDB at 79




More information about the Digitalmars-d mailing list