From: Andrew Wagner Date: 2011-01-05T23:41:34+09:00 Subject: Re: Class Initialization? --0015174bf196939a0904991a6192 Content-Type: text/plain; charset=UTF-8 On Wed, Jan 5, 2011 at 9:33 AM, Kedar Mhaswade wrote: > I have a class and two class methods: self.encode and self.decode. The > encode method expects a class variable (@@table) to be "initialized". > Whereas it's possible to do that in def self.encode(bytes) method of my > class, I was interested to know if I can do that elsewhere (static > blocks, a la Java?). What is the recommended way to do such class > initialization tasks? > > -Kedar > > -- > If I'm understanding right, something like one of these should work: class MyClass @@table = 42; def self.encode(bytes) //... end def self.decode //... end end OR class MyClass def self.initialize_table @@table = ... end initialize_table def self.encode(bytes) //... end def self.decode //... end end --0015174bf196939a0904991a6192--