Ryan Leavengood
6/22/2005 9:23:00 PM
Jeffrey Moss said:
> When I'm working with large structures in IRB, I get a lot of output that
> I can't really read all that well, all the #<Array:0xb75713d8
> @something=>[#<This:0xb75ca550>, #<That:0xb7521d02>]>
>
> With larger objects I can't really tell what I'm looking for or where to
> find it, it's just 100+ lines of garbage really, I'd like it to be
> indented......
>
> Any suggestions how I could format this stuff better?
You know you can override inspect, right?
irb(main):001:0> class Foo
irb(main):002:1> def initialize
irb(main):003:2> @a=['a','b','c']
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> f = Foo.new
=> #<Foo:0x2b5fb48 @a=["a", "b", "c"]>
irb(main):007:0> class Foo
irb(main):008:1> def inspect
irb(main):009:2> "a is #{@a.inspect}"
irb(main):010:2> end
irb(main):011:1> end
=> nil
irb(main):012:0> f
=> a is ["a", "b", "c"]
Also, take a look at pp (pretty printer.)
Ryan