▲ | lajr 4 days ago | |
Strange that they chose to make it `a?["b"] = c;` rather than to use the same syntax as TypeScript (`a?.["b"] = c;`). Honestly I like the C# better, and I was initially not super thrilled about the choice to include the period in the TS case, but since there is some overlap between the language design teams I assumed they would be the same. | ||
▲ | jobigoud 4 days ago | parent | next [-] | |
Where is the dot coming from? If you know the dict is not null you would write a["b"], so it makes perfect sense that the new syntax is a?["b"]. The `?` applies to whatever is to the left of it. a?.Method() has a dot because we would write a.Method(). TypeScript designers made a mistake or had other constraints probably. | ||
▲ | chabska 4 days ago | parent | prev | next [-] | |
Maybe because in JS/TS, `a ? ["b"]` is a valid syntax, so they had to insert the dot to parse properly. | ||
▲ | actionfromafar 4 days ago | parent | prev [-] | |
That would look strange IMHO. Why wouldn't it be a.["b"] then? |