Skip to content

Instantly share code, notes, and snippets.

@OfTheDelmer
Created September 24, 2013 21:21
Show Gist options
  • Save OfTheDelmer/6691440 to your computer and use it in GitHub Desktop.
Save OfTheDelmer/6691440 to your computer and use it in GitHub Desktop.
# User list holds a list of names
# and their shopping items
# Expecting [name, [item1, item2]] style
user_list = []
# Prompting the user if they want to start
puts "Would you like to start a nested list?[y/n]"
response = gets.chomp
while response == "y" || response == "yes"
puts "Give me your name!"
user_list << gets.chomp
puts "Would you like to start a list?"
second_response = gets.chomp
item_list = []
while second_response == "y"
puts "Give me something to put in the list!"
item_list << gets.chomp
puts "Anything else? [y/n]"
second_response = gets.chomp
end
user_list << item_list
puts "Any other people? [y/n]"
response = gets.chomp
end
# this shows the final list
p user_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment