Hi Mauricio, > > No spaces are used when the element doesn't exsist in the other object. For > > example: > > OK, I see it now. Implementing this is however quite complicated (ie. > not as easy as what I'm doing now :) Which may explain why your code was so clean :-). I'd like to see what would happen if you did add this functinality. I may try and do this myself if I have time this weekend and see how easy it is. But I agree the problem does get much more complicated when you add the spaces. > > a = { :a => 1, :b => 2, :c => 3} > > b = { :b => 2, :c => 3} > > > > so ['{ :a => 1, ... ...}', '{ ... ...}'] would be the output of > This can get quite ugly if the iv. refers to an object whose text > representation is "big" and you have line wrapping. True, but this would be a case where turning linewrapping on would really help. The number of spaces by the way is determined by the length of the ivname => iv combination so when the lines are printed in parallel it really helps. > > A couple of things I haven't figured out: > > > > 1. What does ruby use when outputting the object id for object.inspect? > > Either I can't get the formatting right, or it's not the object id. (Compare > > object_to_s with inspect.) > > It uses the address of the object: > > static VALUE > rb_obj_inspect(obj) > VALUE obj; > { > ... > if (rb_inspecting_p(obj)) { > str = rb_str_new(0, strlen(c)+10+16+1); /* 10:tags 16:addr 1:nul */ > sprintf(RSTRING(str)->ptr, "#<%s:0x%lx ...>", c, obj); > RSTRING(str)->len = strlen(RSTRING(str)->ptr); > return str; > } > ... > str = rb_str_new(0, strlen(c)+6+16+1); /* 6:tags 16:addr 1:nul */ That makes sense. But it begs the question: how do you get the address of an object in ruby? > > 2. How do you handle fringe classes that are descendants of Array, Hash, > > String, etc... intelligently? For instance say A < String and has an > > instance variable. How do you print this and note the difference? (Or should > > you even bother?) > > perhaps introducing a notation like > <MyArrayClass:0x12345678 [... 1, 2, ..., 3] @a=1> So you would use the above whenever the object was a kind_of?(Array) but not a instance_of?(Array) ? -- John Long http://wiseheartdesign.com