Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Created March 3, 2020 22:38
Show Gist options
  • Save harrisonmalone/f2f71b1f248d3aa7dee36cb5dd9ec7fb to your computer and use it in GitHub Desktop.
Save harrisonmalone/f2f71b1f248d3aa7dee36cb5dd9ec7fb to your computer and use it in GitHub Desktop.
users = [
{
username: "emma",
email: "[email protected]",
address: "1 Bourke Street, Melbourne"
},
{
username: "paul",
email: "[email protected]",
address: "120 Spencer Street, Melbourne"
}
]
def view_contacts(users)
# loop through array of hashes
puts "-" * 27
for people in users
puts "username: #{people[:username]}"
puts "email: #{people[:email]}"
end
end
def menu
puts "1. View contacts"
puts "2. Add contact"
puts "3. Remove contact"
puts "4. Exit"
puts ""
puts "whats your selection? (pick between 1 and 4)"
print "> "
user_input = gets.chomp.to_i
end
while true
input = menu
case input
when 1
view_contacts(users)
when 2
puts "add contacts"
when 3
puts "delete contacts"
else
exit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment