From: Run Paint Run Run Date: 2009-05-29T06:15:16+09:00 Subject: [ruby-core:23601] [Bug #1533] Inconsistency Between Hash#to_s and Hash#inspect Bug #1533: Inconsistency Between Hash#to_s and Hash#inspect http://redmine.ruby-lang.org/issues/show/1533 Author: Run Paint Run Run Status: Open, Priority: Normal ruby -v: ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux] There is an inconsistency between Hash#to_s and Hash#inspect with respect to recursive data structures. For example: $ ruby -v -e 'x={};x[0]=x;p x.to_s' ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux] "{0=>{0=>{...}}}" $ ruby -v -e 'x={};x[0]=x;p x.inspect' ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux] "{0=>{...}}" $ ruby1.8 -v -e 'x={};x[0]=x;p x.to_s' ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] "0{...}" $ ruby1.8 -v -e 'x={};x[0]=x;p x.inspect' ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] "{0=>{...}}" ujihisa noticed that it was caused by a similar issue to the bug he reported in http://redmine.ruby-lang.org/issues/show/1427 . He produced a patch in less time than it took me to type this report, which I have attached. He provides the following demonstration of its result: #!./ruby -v # ruby 1.9.2dev (2009-05-28 trunk 23601) [i386-darwin9.7.0] x = {} x[0] = x puts x.to_s #=> {0=>{0=>{...}}} puts x.inspect #=> {0=>{...}} # After the patch: puts x.to_s #=> {0=>{...}} puts x.inspect #=> {0=>{...}} Thanks! ---------------------------------------- http://redmine.ruby-lang.org