Ruby Ruby Loops Build a Simple Contact List Assigning Hash Values From Methods

NameError: undefined local variable or method `contact' for main:Object

undefined contact

contact.rb
contact_list = []

contact = {"name" => "", "phone_number" => "" }
def get_name

  contact.each do |key , value|
    value=contact['name']
  end
  return value
end
get_name()

2 Answers

Also your variable is contact_list not contact. That's why it's undefined