From: Judson Lester Date: 2009-11-12T09:41:49+09:00 Subject: Re: Need help to detect error --001636e0a681865264047821ba29 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable That's bizarre. All that I can see that's different is because the failing version uses the attribute "bparent" and the other uses "parent", the backreferences occur in different places in the resulting YAML. I believe that Syck was taking over when _why left - you ought to file a bug. (Unless there's an obscure YAML rule that backreferences have to occur afte= r literal values...) Judson 2009/11/11 V=C3=ADctor Adri=C3=A1n > Or anyone knows where can I contact some YAML guys to help me with this > obscure problem? > > El mi=C3=A9, 11-11-2009 a las 16:58 +0900, V=C3=ADctor Adri=C3=A1n de la = Cruz Serrano > escribi=C3=B3: > > I don't know what am I doing wrong, can anyone help me? > > These two programs look very similar, but they yield different results. > > Can anyone confirm this "error"? > > > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > # FAILING EXAMPLE > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > class Battlefield > > attr_accessor :teams > > def initialize > > @teams =3D [] > > end > > def add_team(team) > > @teams << team > > team.bparent =3D self > > end > > end > > > > class Team > > attr_accessor :members, :bparent > > def initialize > > @members =3D [] > > @bparent =3D nil > > end > > def add_member(child) > > @members << child > > child.team =3D self > > end > > end > > > > class Warrior > > attr_accessor :team > > def initialize > > @team =3D nil > > end > > end > > > > w =3D Warrior.new > > t =3D Team.new > > t.add_member(w) > > b =3D Battlefield.new > > b.add_team(t) > > b.inspect > > #Convert to YAML and back > > y =3D YAML.load(b.to_yaml) > > #Now have a look at the "members" array inside a team... it's gone > > y.inspect > > y.teams.first.members.inspect > > > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > # GOOD EXAMPLE > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > require 'yaml' > > > > class Battlefield > > attr_accessor :teams > > def initialize > > @teams =3D [] > > end > > def add_team(team) > > @teams << team > > team.parent =3D self > > end > > end > > > > class Team > > attr_accessor :members, :parent > > def initialize > > @members =3D [] > > @parent =3D nil > > end > > def add_member(child) > > @members << child > > child.team =3D self > > end > > end > > > > class Warrior > > attr_accessor :team > > def initialize > > @team =3D nil > > end > > end > > > > w =3D Warrior.new > > t =3D Team.new > > t.add_member(w) > > b =3D Battlefield.new > > b.add_team(t) > > b.inspect > > #Convert to YAML and back > > y =3D YAML.load(b.to_yaml) > > #Now have a look at the "members" array inside a team, it's still there > > y.inspect > > y.teams.first.members.inspect > > > > > > > > > > --001636e0a681865264047821ba29--