Learning objectives:

  • Working with Strings – concatenation
  • Working with 1-D arrays – accessing elements, count
  • Multidimensional arrays – 2D- and 3D-arrays, accessing elements, count
  • Traversing arrays – for-loops and nested-loops
  • Ragged- or jagged-arrays;  definition, applications and using loops to traverse jagged arrays
  • Random numbers


Students are lead through a series of activities working with Strings, random numbers, 1D, 2D and 3D ragged arrays with the culminating activity: a Swift program that creates a series of randomly-generated Haiku poems.


Swift Playground Book Description: Haiku

The first activities in this Swift Playground Book: Haiku introduce the ideas of String concatenation.  Also, random number generation is presented.

In the second set of activities, students are required to access specified elements in a 1-D array of Strings.  Then they are

required to access the last element of a 1-D array of Strings and finally, a random element among a given array of Strings.

There is a “cut-scene” that walks through traversing an array:

Next, 2-D arrays are introduced with a cut-scene that illustrates a multidimensional arrays as an “array of arrays.”  This conceptual model is particularly useful when students are working with jagged arrays, as in this example.

Near the end of the challenge, students are lead through a code-highlighting activity where they watch a nested-for-loop execute and access all

the elements in a jagged array of Strings.

With all these new tools at their disposal, the final activity invites students to write a program that will produce a sequence of randomly-generated Haiku poems.

Leave a Reply

Your email address will not be published. Required fields are marked *