From: Bertram Scharpf Date: 2007-07-24T21:31:33+09:00 Subject: Re: Static variables in Ruby. Hi, Am Dienstag, 24. Jul 2007, 18:03:15 +0900 schrieb Robert Dober: > On 7/24/07, Marcin Tyman wrote: > >Is any way to define static variables over function? As class static > >variables there is possible to define a static class variable as > >@@name_of_var. But I'm not sure if Ruby let define such variables in > >functions (like in C/C++) > There are three kinds of variables in Ruby > local > @@class_var > @instance_var Further $global which I use almost never (except $1, $> etc.). > My tip, do not use @@class_var, use @inst_var on the correct level > > class A > @count = 0 > class << self > attr_accessor :count > end > end So do I. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de