On Dec 29, 2005, at 11:08 AM, Steve Litt wrote:

> When we write:
>
> attr_accessor :wilbur
>
> what really happens is that the function attr_accessor() takes  
> symbol :wilbur
> as an argument, tacks on a @ to the string's value in order to make  
> the true
> class variable @wilbur,

That's an instance variable, not a class variable.

As Austin taught us yesterday, it doesn't make the variable either,  
just some methods.

> and then writes a tiny get and set functions whose
> names are wilbur, such that:
>
> my_object.wilbur = 22
> puts my_object.wilbur
>
> So my initial comment that it seemed like magic is true only to the  
> extent
> that the "magic" performed by attr_accessor is to create the set  
> and get
> methods with the same name as the symbol that is its argument.

"Magic" to me is the tricky stuff and I don't see any of that here.   
We just told it the name for a method we wanted.  You could easily  
code a pure Ruby replacement for the attr* methods, so it's really  
just a shortcut with Ruby doing some work for you.  No magic there.

James Edward Gray II