O'Reilly logo

Get Programming with Go by Nathan Youngman and Roger Peppé

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required