[#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:01931] Re: Class Variables

From: Dave Thomas <Dave@...>
Date: 2000-03-16 22:13:15 UTC
List: ruby-talk #1931
"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


Dave

In This Thread