List
List is a group of value in order, sorted by their index.
List is analogous to put the value in each drawer and access them by referring drawer 1, drawer 2, etc.
Use list for general purpose of grouping several value in single variable. This save some variables spaces and give a single unit container for similar group of data.
Example :
Code: Select all
name = newList("Andy", "Bob", "Charles");
second = name[1]; //second index in list is Bob
Map
Map is a kind of dictionary, with key-value mapping. The key-value always come in pair.
It is analogous to search the dictionary for word "Magic" (key) to get the meaing "the power of apparently influencing the course of events by using mysterious or supernatural forces" (value)
Use map for value lookup.
Example :
Code: Select all
scores = newMapFromValues("Andy", 87, "Bob", 42, "Charles", 100);
charles_score = scores["Charles"; // charles_score will be 100
I have longer explanation o differentiate the usage of each, nested map/list, conversion, including what you can do to them. But mostly theory and might be confusing for now. Better save it for future case.