awesome-print / awesome_print

Pretty print your Ruby objects with style -- in full color and with proper indentation
http://github.com/michaeldv/awesome_print
MIT License
4.07k stars 454 forks source link

Struct strange output #361

Open StefanoMartin opened 5 years ago

StefanoMartin commented 5 years ago

I noticed a strange behavior when I use awesome print with Struct and one of the attribute is ":s"+other_attribute.

Here an example:

require "awesome_print"
require "ostruct"

A = Struct.new(:a, :sa)
ap A.new(1,2)

===> 
#<Struct:A:0x5561e5934cd8
    a = 1,
    attr_accessor :a = 2
>

Instead of the expected:

#<Struct:A:0x5561e5934cd8
    a = 1,
    sa = 2
>
randyjap commented 5 years ago

This appears to be caused by an indexing error into the variables. I have opened a PR to fix this. https://github.com/awesome-print/awesome_print/pull/363