Q:

How do I change the way objects are displayed?

In this script, I take user input, pass it to an object, and then push that object into an array. I then iterate over that array:
objects_array = Array.new

class Object
  def initialize(fname)
    @first_name = fname
  end
end

fname = gets.chomp
user_first = Object.new(fname)
objects_array <<  user_first
objects_array.each {|x| print x}

I gave the input "Tyler" from the terminal, and the results that I am expecting is:
Tyler

but I do not retrieve those results. Instead of the object string, I receive the memory location:
#<Object:0x26f00b8>

I am having trouble referencing the information of an object that is located in an array. What do I need to change to receive the information of the object in the array rather than the memory location?

A:

Ruby cannot print an Object (present as a string) in a nice way without a proper to_s method. If there is no to_s method then Ruby's fallback is an internal method that just takes the class name and the object id.
You need to add a to_s method to your model:
class Object
  def initialize(fname)
    @first_name = fname
  end 

  def to_s
    @first_name
  end
end

