From: Eric Mahurin Date: 2005-10-27T05:11:26+09:00 Subject: Re: overriding #inspect > --- Sean O'Halpin wrote: > > > On 10/26/05, Eric Mahurin wrote: > > > Anybody know what the best way to override inspect where > > you > > > may have a recursive data structure? > > > > Check out Tanaka Akira's 'pp' lib (if only to convince > > yourself that > > there's no silver bullet!) Actually, as soon as I allowed myself to make an instance variable, it didn't seem so bad. Here's what I came up with: def inspect to_s[0..-2].concat(" #{ if defined?(@inspecting) "..." else begin @inspecting = true ... generate inspect contents here ... ensure remove_instance_variable(:@inspecting) end end }>") end __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com