Skip to content

Instantly share code, notes, and snippets.

@chhhris
Created June 10, 2013 20:13
Show Gist options
  • Save chhhris/5751865 to your computer and use it in GitHub Desktop.
Save chhhris/5751865 to your computer and use it in GitHub Desktop.
# Construct an array with your favorite foods. It should have at least 5 elements.
fav_foods = ["penne pasta with garlic and oil", "yellow cherries", "milk shakes", "french fries", "bacon cheeseburgers"]
# Write a puts which returns your most favorite food out of the array.
fav_foods[4]
# 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[0, 3]
# Create an empty array.
empty = [""]
# Assign values to the the second and 6th position.
empty[1] = "Tacos"
empty[5] = "Fajitas"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment