Skip to content

Instantly share code, notes, and snippets.

@stevenabrooks
Created June 10, 2013 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenabrooks/5752400 to your computer and use it in GitHub Desktop.
Save stevenabrooks/5752400 to your computer and use it in GitHub Desktop.
#Construct an array with your favorite foods. It should have at least 5 elements.
array = ['Lobster', 'Bacon', 'Steak', 'Grilled Chicken', 'Ice Cream']
#Write a puts which returns your most favorite food out of the array.
puts array[0]
#Construct an array with the colors of the rainbow (ROYGBIV)
rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']
#Slice the colors Red, Orange, and Yellow out of the array.
rainbow.slice(0, 3)
#Create an empty array.
array = []
#Assign values to the the second and 6th position.
array[1] = 'Crabs'
array[5] = 'hello'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment