Search Unity

Dictionary without initialization? (in text adventure tut)

Discussion in 'Community Learning & Teaching' started by Lednar, May 14, 2018.

  1. Lednar

    Lednar

    Joined:
    Jan 9, 2018
    Posts:
    14
    I am following Creating a Text Based Adventure Part 2 - Taking Items [5/10]


    A dictionary is used (in 6:15 min) without initializing first like this:

    Dictionary<string, string> takeDictionary = controller.interactableItems.Take(separatedInputWords);


    Shouldn't you first initialize it? Or use like this:

    Code (csharp):
    1. Dictionary<string, string> myDict = new Dictionary<string, string>
    2.         {
    3.             { "key1", "value1" },
    4.             { "key2", "value2" }
    5.         };