Arrays and their Operations

Let's learn how to access the contents of an array and learn how to use built-in methods in this lesson.

As we discussed earlier, an array is like a list of values. The simplest form of an array is indexed and ordered by an integer starting with index 0.

Note: To debug your code while working with arrays, it is very important to view the keys and their associated values. Accessing the length of an array can also be useful on numerous occasions.

Outputting a structured view of arrays

To print an array in a readable format, we use the following statement:

print "@arrayName";

This statement will print the contents of the array separated, by a space. Run the code below to see how print works with arrays.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy