Understand arrays, collections, and elements

In this video, you will learn:

  • How data is commonly organized into arrays, collections, and elements
  • The difference between simple and complex arrays
  • How to work with simple and complex arrays
Transcript
Up to this point in the training, we’ve worked with data arrays, collections, and mapped items in a variety of ways, but we haven’t really stopped to take a closer look at what they are, how they’re connected, and how to effectively use them in your scenarios. Arrays, collections, and elements are all outputs that you might receive from a module in your scenario. What you receive as outputs will depend on the platform API and the modules used. As you’ve learned up to this point, you can use the mapping panel and formula editor to have endless possibilities for how you use the output data throughout your scenarios. An array is a set of variables that are referenced using a single variable name combined with an index number. Consider it a type of structure as part of an API, and depending on the API structure, arrays may be indexed starting from zero, meaning the first variable is variable zero. Other APIs are indexed from one instead of zero. Depending on the structure of an array, they can be considered either a simple, sometimes called primitive array, or a complex array. A simple array will be composed of a variable list of elements, which can be a simple list of numbers or single pieces of information. A complex array can be structured in a variety of ways, consisting of individual elements, collections, additional arrays, or any combination of the three. Consider each element, collection, and additional array within an array to be a different variable. Each indexed variable in an array will be set up as key value pairs, meaning that for each variable in the array, there is an index number, a key, or what you might consider a label and a value. A collection is like an array in that it can contain combinations of arrays, elements, or even additional collections, but what makes up a collection and its structure isn’t variable. Looking at the example at the right, each of the three collections contains the same information and structure of information, base_stat, effort, and a stat collection. The stat collection is made up of a name and URL. Now, that is a lot to digest, we totally get it. With the help of upcoming walkthrough exercise videos, the concepts of arrays should start to make more sense. What’s important to remember walking away from this video is that an array is structured data containing information that you’ll want to use in your scenarios. Also remember that the structured data within an array is variable, meaning an array might contain zero, one, or multiple sets of structured data. Collections on the other hand are structured data, but not variable. In the upcoming walkthrough videos, we’ll highlight some of the scenarios we’ve already built and where we’ve already used simple and complex arrays. Hopefully, we’ll help you connect the dots by combining the concepts with familiar examples. -
recommendation-more-help
c9fbcf61-6d19-481e-a9ab-f54a0ae0ee8a