[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: attr_reader as a class method

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).