Arrays
Think of an array as a that can hold more than a single object, something like a variable with one or many values. Imagine you have a few friends and you want to write down their names:
friend_1=Anthony friend_2=Mike friend_3=Noel friend_4=Tarek friend_5=Dionysios
Once you have the variables instanced, you can then deference them, deferencing being the act of retrieving a value. This is OK, but it somehow cages you into some limitations, such as you must call the exact variable name to access its value, you cannot easily cycle between them, you cannot tell the number of values so quickly, and more. For such operations, there is an appropriate structure, which comes at hand and allows us to work on the values as a single entity--this is the array:
friends=(Anthony Mike Noel Tarek Dionysios)
The elements inside an array are indexed, and its position is assigned during the assignment, so Anthony
will be at the first position and Dionysios
at the fifth. But once declared and instanced, we...