Dave Thomas wrote:
>
> On Mar 16, 2008, at 8:56 AM, Tom Cloyd wrote:
>
>> I'm exploring the wonders of the Object class, and I see 
>> Object#to_yaml. Seems pretty obvious what to expect here, which would 
>> seem to account for the total lack of documentation in each of the 
>> gazillion instances of this method which appear in core library. 
>> Still, let's test it...
>>
>> irb(main):010:0> [2,5,3,6,'abc'].to_yaml
>> NoMethodError: undefined method `to_yaml' for [2, 5, 3, 6, "abc"]:Array
>>       from (irb):10
>>       from :0
>>
>> Can someone explain what just happened?
>
>
> Tom:
>
> Could you tell us just where you found the description of Object#to_yaml.
>
> As others have explained, to_yaml is not a built-in method. It is 
> added when you require the yaml library. So, if a piece of 
> documentation is out there that fails to make it clear that this 
> library must be loaded before to_yaml is called, then that 
> documentation needs to be fixed.
>
> As others have also pointed out, once the library is loaded, you can 
> indeed invoke to_yaml on arrays, hashes, and so on.
>
>
> Regards
>
>
> Dave Thomas
>
>
OK...now THIS is the reaction I was really looking for, which is why I 
provided the documentation I did in my first two emails. From my point 
of view, and as your response here would seem to support, beginners like 
me can, in exploring the interface to Ruby (part of which is its 
available documentation) find glitches which those of you with expert 
knowledge all too easily miss. We are, in fact, a uniquely valuable 
resource, I would hope. I'm trying to be, in any case.

So...here's the path to the documentation (can't give an specific URL, 
due to use of frames):
1. go to http://www.ruby-doc.org/core/
2. in the middle panel, select the Object class.
3. scroll down to Methods, and find the to_yaml method
4. clicking on that, you'll see there's no documentation. So, go back to 
the top of the Object's page, and see the sentence I noted in my second 
email: "  Object is the parent class of all classes in Ruby. Its methods 
are therefore available to all objects unless explicitly overridden."

To my mind, there is nothing here that suggests that I must "require" 
anything to get access to this method. Hence my (enduring) bewilderment. 
Were I more knowledgeable about object inspection, I'd have seen why I 
got the irb error I did, but still would not have know why irb blocks 
this method.

I hope this helps the cause, and thanks for your interest.

t.

-- 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC
Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< tc / tomcloyd.com >> (email)
<< TomCloyd.com >> (website & psychotherapy weblog) 
<< sleightmind.wordpress.com >> (mental health issues weblog)
<< directpathdesign.com >> (web site design & consultation)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~