List and Map variables

Post your questions and help other users.

Moderator: Martin

Post Reply
Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

List and Map variables

Post by Wibbly » 22 Jan 2020 14:46

Can anyone point me to a definition of these and when to use each in Automagic?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: List and Map variables

Post by Desmanto » 23 Jan 2020 18:00

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.
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.

Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

Re: List and Map variables

Post by Wibbly » 23 Jan 2020 19:31

Thanks

Post Reply