Lesson 16. Arrayed in splendor

After reading lesson 16, you’ll be able to

  • Declare and initialize arrays
  • Assign and access the elements of an array
  • Iterate through arrays

Arrays are ordered collections of elements with a fixed length. This lesson uses arrays to store the names of planets and dwarf planets in our solar system, but you can collect anything you like.

Consider this

Do you have a collection or did you in the past? Maybe stamps, coins, stickers, books, shoes, trophies, movies, or something else?

Arrays are for collecting many of the same type of thing. What collections could you represent with an array?

16.1. Declaring arrays and accessing their elements

The following planets array contains exactly eight ...

Get Get Programming with Go now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.