Getting a Human-Readable Printout of Any Object : to String « Class « Ruby






Getting a Human-Readable Printout of Any Object


a = [1,2,3]
puts a
puts a.to_s
puts a.inspect
puts /foo/          # (?-mix:foo)
puts /foo/.inspect  # /foo/

 








Related examples in the same category

1.class to string
2.Override a to_s method after inheritance
3.Format ourselves as a string by appending our lyrics to our parent's #to_s value.