(SOLVED) Dictionary error: Invalid set index 'TITLE' (on base: 'String') with value of type 'String'.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By The_Black_Chess_King

I am re-adding this question to help anyone finding the same issue, because my original question that I found this, had a mislead title. Why? Because I couldn’t find anything to help me with this specific problem.

If you set a dictionary like:

var TITLE = loadedDate[0][2]#Just a example of a array stored with the Title

Library[TITLE_CATEGORY] = TITLE
Library[TITLE_CATEGORY][TITLE] = "Subtitle"

It will return a error like:

##Invalid set index ‘TITLE’ (on base: ‘String’) with value of type ‘String’.

:bust_in_silhouette: Reply From: The_Black_Chess_King

Because TITLE was set only as a string, the loadedDate[0][2] is just a string. So it was trying to add a dictionary subkey to a string,

The correct way of doing it is to keep it a dictionary if you want to add sub-keys:

Library[TITLE_CATEGORY] = {TITLE:"Subtitle"}

Now TITLE is a dictionary and can be referenced properly:

Library[TITLE_CATEGORY][TITLE]