[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01932] Re: Class Variables

From: "David Douthitt" <DDouthitt@...>
Date: 2000-03-16 22:24:25 UTC
List: ruby-talk #1932
| "David Douthitt" <DDouthitt@cuna.com> writes:
| 
| > I DID find class constants (see I do read the manual! :-)
| > 
| > But I ALSO want to be able to do:
| > 
| > fooey.setting1 = 6;
| 
| Ah-ha! In that case, you want to use attributes
| 
|   class Foo
| 
|     attr_accessor :setting1, :setting2
| 
|     def initialize
|        @setting1 = 2
|        @setting2 = 5
|     end
|   end
| 
|   c = Foo.new
| 
|   p c.setting1 + c.setting2
| 
|   c.setting2 = 7
| 
|   p c.setting1 + c.setting2

Doesn't that work only in modules?  I can't find 'attr_accessor'
and others anywhere except in the Module class.

...dave

In This Thread

Prev Next