[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

adding attributes (attr_*-style) to single objects

dblack

7/12/2005 11:26:00 AM

4 Answers

Joel VanderWerf

7/12/2005 4:55:00 PM

0

David A. Black wrote:
...
> class C
> add_attr_accessor(:x)
attr_accessor(:x)
> end

The method names are too close. I would have guessed these did the same
thing.

I like the idea, but why not just make #attr_accessor public, so you can
write:

self.attr_accessor :x

and make it clear that you are not adding an instance method.


Joel VanderWerf

7/12/2005 5:01:00 PM

0

Joel VanderWerf wrote:
> David A. Black wrote:
> ...
>
>> class C
>> add_attr_accessor(:x)
>
> attr_accessor(:x)
>
>> end
>
>
> The method names are too close. I would have guessed these did the same
> thing.
>
> I like the idea, but why not just make #attr_accessor public, so you can
> write:
>
> self.attr_accessor :x
>
> and make it clear that you are not adding an instance method.


Duh. That suggestion made no sense.

Maybe something like

my_attr_accessor :x

to add an accessor to the current self, rather than to instances of the
current self.


Daniel Brockman

7/12/2005 5:21:00 PM

0

dblack

7/12/2005 5:26:00 PM

0