Ryan Davis
7/9/2006 7:25:00 AM
On Jul 9, 2006, at 12:17 AM, Minkoo Seo wrote:
> I'd like to use attr_reader to introduce a class method. For example,
> the following is the code I've tried.
>
> irb(main):001:0> class Foo
> irb(main):002:1> ONE = 1
> irb(main):003:1> end
The example is simply flawed. ONE is a constant and can be accessed
from outside Foo as Foo.ONE without any extra code. attr_* don't
provide access to constants, only instance variables (including the
instance of a class).