4.7. Getting a Random Item From an Array

Getting random items from an array can be done by indexing the array using random and sizeof:

Example 4-11. Getting a random item from an array


  string *colors = ({ "red", "blue", "green", "yellow" });
  set("short", "A " + colors[random(sizeof(colors))] + " banana");