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

From: Dave Thomas <Dave@...>
Date: 2000-03-16 22:00:22 UTC
List: ruby-talk #1928
"David Douthitt" <DDouthitt@cuna.com> writes:

> How do I do the equivalent of something like this....
> 
> Class Foo
>     setting1 = 2;
>     setting2 = 5;
> 
>     def ....
>     def ...
> end
> 
> fooey = Foo.new;
> print fooey.setting1
>     2
> print fooey.setting2
>     5
> print fooey.setting2 + fooey.setting1
>     7

Using class constants:

 class Foo
   SETTING1 = 2;
   SETTING2 = 5;
 end

 p Foo::SETTING1
 p Foo::SETTING2 + Foo::SETTING2


Regards


Dave

In This Thread

Prev Next