It replaces a 'magic string' with a 'magic variable name', which is worse than the normal solution for magic strings, which is to move them to a constant.
If I have code in one place that says:
dict["key"] = "value";
and code elsewhere that says: var value = dict["key"];
I can make that code better today by adding const string KEY = "key"
and then using dict[KEY] in both places. I can change the key in one place, and if I misspell the constant name in either location then the compiler tells me I have a problem.With the new syntax, I can now write
dict.$key = "value";
and var value = dict.$key;
but if I go ahead and change one of these: dict.$newkey = "value";
I'm not going to get a compiler warning when I try to read $key (am I?). Unless there's some smart tooling support, where's the win here?Key symbols aren't becoming a new type - I don't get to write
var key = $key;
var big_key = ["key with spaces"];
(so far as I'm aware - though I actually quite like the idea of a datatype that represents this kind of non-manipulable string identifier)I guess the new .$ syntax combines with the null-propagating ?. operator, so you could have nested dictionaries and access them with:
dict?.$subdict?.$subsubdict
which looks... horrible. And suffers from the fact that there's no null-propagating equivalent index access operator, ?[], so I can only use this trick on keys that can be written as C# symbols.
I really feel like I'm completely missing what the use cases are for this capability...