Created
September 24, 2013 21:21
-
-
Save OfTheDelmer/6691440 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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