From: Stefano Crocco Date: 2008-05-22T04:49:03+09:00 Subject: Re: to_yaml method for array On Wednesday 21 May 2008, James Britt wrote: > > I go to http://www.ruby-doc.org/core/ and look for Array methods. I see > > to_yaml. So why in the irb I am getting undefined method to_yaml? > > rdoc, run over the ruby source, is dopey in that it parses the yaml > files, sees that they modify core Ruby objects, then generates rdoc that > presents those core objects as if they had yaml methods built-in. > > In actual practice, you have to explicitly mix-in yaml to get that > behavior. Actually, you don't need to mix-in yaml. When you require yaml.rb, it will add the generic to_yaml method to the Object class itself (or to the Kernel module, I'm not sure) and the more specialized methods to those classes for which they exist (such as Array, String and Hash). There's no mixing-in involved, as far as I can tell. Stefano