On Mar 3, 2007, at 15:25, Austin Ziegler wrote: > On 3/3/07, Tim Becker <a2800276 / gmail.com> wrote: >> On 3/3/07, libsfan01 <mcyi2mr3 / googlemail.com> wrote: >> > can someone explain how attr_reader works? >> > i can't find a good explanation anywhere. >> It's built in to the language, so it 'works' by magic for all >> practical purposes, it's implemented in `object.c` if you want to >> take >> a look at the implementation. If you wanted to implement it in Ruby, >> you do something like this: > > Actually, that's not true. It's written in C, but that's not the same > as being built into the language. It's a method on Module, so it *can* > be overridden. attr* also cheats, so methods defined by attr* are slightly faster than methods defined with def: http://blog.segment7.net/articles/2006/03/06/attr-vs-method-vs- define_method