List and Map variables
Moderator: Martin
List and Map variables
Can anyone point me to a definition of these and when to use each in Automagic?
Re: List and Map variables
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 :
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 :
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.
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 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
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.