I have a custom class called Thing, and an array of Thing objects, like this:
class Thing
attr_accessor :name
def initialize(name)
@name = name
end
def to_s
@name
end
end
a = []
a << Thing.new("Fred")
a << Thing.new("George")
a << Thing.new("Steve")
a
When I look at the array in irb, I want it to look like this:
[Fred, George, Steve]
rather than this (the object information): [#, #, #]
In other words, I'd like to be able to see to to_s value of each element in the array when I look at the array with irb. Is there a way to do this?