attr_accessor, attr_reader question 
Author Message
 attr_accessor, attr_reader question

Is there a way that I can use attr_accessor or attr_reader so that I
can access a boolean variable with a '?' appended to the end of the name?
For example:
class Test
  attr_accessor :bit
end
t = Test.new

That will allow 't.bit = true', or 'if t.bit' but it won't do 'if t.bit?',
which is clearer, IMO.

-Michael



Thu, 06 Jan 2005 16:01:26 GMT  
 attr_accessor, attr_reader question
Hi,

At Sun, 21 Jul 2002 17:00:50 +0900,

Quote:

> Is there a way that I can use attr_accessor or attr_reader so that I
> can access a boolean variable with a '?' appended to the end of the name?
> For example:
> class Test
>   attr_accessor :bit
    alias bit? bit
> end

--
Nobu Nakada


Thu, 06 Jan 2005 16:29:27 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. attr_reader/writer vs. attr_accessor w/ access control

2. Ruby code for attr, attr_accessor, attr_reader, attr_writer ?

3. attr_accessor question

4. attr_accessor?

5. dynamic attr_accessor??

6. dynamic attr_accessor again using a hash

7. attr_accessor in base class

8. attr_accessor in base class

9. attr_reader :foo?

10. attr_reader, etc.

11. druby/attr_reader problem

12. attr_reader for great number of instance vars

 

 
Powered by phpBB® Forum Software