AnswerWhat does this code do?
This was a surprising shock, this code seems so simple, but it does something very different than what I would expect.
The question is why?
As it turns out, we are missing one character here:
Notice the lack of the comma? Let us see how the compiler is treating this code by breaking it apart into steps, shall we?
First, let us break it into two statements:
Note that we moved the name line into the first statement, since there isn’t a command here. But what is it actually doing? This looks very strange, but that is just because we have the dictionary initializer here. If we drop it, we get:
And that make a lot more sense. If we’ll break it all down, we have:
And that explains it all, make perfect sense, and a very nasty trap. We run into it accidently in production code, and it was near impossible to figure out what was going on or why it happened.