class Person attr_reader = :name, :location def initialize(name, location) @name = name @location = location end end persons_array = [Person.new("Shon", "Texas"), Person.new("Michael", "California"), Person.new("Chris, "california") ] I am trying to iterate through the array above and display "Shon is in Texas." I tried persons_array.each { puts "#{@name} is in "#{location}", but no luck.
[Person.new("Luke", "big trouble")].map { |obj| "#{obj.instance_variable_get(:@name)} is in #{obj.instance_variable_get(:@location)}" } => ["Luke is in big trouble"].