Key Concepts

Review core concepts you need to learn to master this subject

Go Arrays

In Go, an array is a fixed size ordered list of elements with the same data type. Arrays are useful for collecting and accessing multiple related values. Example use cases include:

- Storing sensor values - Computing averages - Holding lists of information
Arrays and Slices
Lesson 1 of 1
  1. 1
    Imagine we are creating an online gaming platform, and need to keep track of players’ scores. For each player, we’d need to store their score at a consistent index for that player. This is a situat…
  2. 2
    To use arrays in our programs, we must first declare and name them. In Go, there are a variety of ways in which we can declare an array. In the next few exercises, we will explore methods of array …
  3. 3
    While empty arrays are useful, so are arrays already populated with elements! Sometimes we already know which values we are going to put in our array. Imagine we are doing some math homework, and …
  4. 4
    We’ve learned how to create arrays that contain values. But how can we access the values stored in arrays? While having a list of numbers in a program might look nice, we need to access values to …
  5. 5
    Being able to retrieve the values stored in our array is super helpful, but what if we need to change them? Changing an array value is something that happens all the time in professional programs. …
  6. 6
    So far we’ve been using arrays, which have a fixed size. If we were to want to store a different number of elements in our array, we’d have to make a whole new one. However, Go provides us with a u…
  7. 7
    Why might we need to find the length of an array? Describe a scenario or scenarios in which this would be useful. ### len len is a function which returns the length of an array or slice passed in…
  8. 8
    So far we have covered what arrays and slices are, and how to work with them at a basic level. However, a big aspect of working with slices are that we can add elements and the slice will resize au…
  9. 9
    All of this array and slice functionality is useful, but we need to be able to use it outside of main. In this exercise, we will learn to define functions which allow us to repeat functionality usi…
  10. 10
    Throughout this exercise, we have introduced concepts and syntax related to using arrays and slices in our Go programs. Let’s take a moment to review what we’ve learned. An array is a fixed size o…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo