From: Matthew Desmarais Date: 2005-11-22T04:59:24+09:00 Subject: Re: Problem with Pickaxe and Yaml Mark Haliday wrote: >Daniel.Berger wrote: > > > >>No. There's no "[]" method defined. Try 'puts obj'. >> >>That line isn't in the example, btw. >> >>Regards, >> >>Dan >> >> > > >But a similar example is used on page 758 (near the bottom of the page). > >If I just do a: > >puts obj > >It puts out both values, when I just want to get the one in "valuable". > >Thanks. > > When you write "puts obj" you are calling puts with the object 'obj' as a parameter. The prints the result of obj.to_s to stdout. The to_s method for an object typically returns a string. You can see that in the example the to_s method is defined as returning a string containing the values of three instance variables. Perhaps part of the confusion has to do with the to_yaml_properties method. The to_yaml_properties method is only a clue indicating which data you would like included in the yaml-ization of an object and not what you can expect from dumping the object. The difference between the example on the bottom of page 758 and your example is that the object loaded in the pickaxe example is a Hash and so it responds to the [] method. I hope that I've helped more than confused. Matthew