Override the inspect the method to provide a better print out : inspect « Class « Ruby






Override the inspect the method to provide a better print out


class Dog
  def inspect
    "<A Dog named #{@name} who's #{@age} in dog years.>"
  end

  def to_s
    inspect
  end
end

spot = Dog.new()

puts spot.inspect

 








Related examples in the same category

1.Print out a class