From: Lucas Date: 2009-01-24T05:33:03+09:00 Subject: Re: class 'initialize' method not working ??? --0016369205b18a74fc04612c3bf7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Remove the 'end' after @dbs = dblist On Fri, Jan 23, 2009 at 6:09 PM, Tom Cloyd wrote: > I'm baffled by this error, after a hour+ of experimentation with solutions. > I assume it's a compiler error (right term in Ruby?), as I'm not even > getting access to ruby-debug. > > Code snippet: > ======= > def main > > opdb = Open_db.new( [1,2,3] ) > > end > > class Open_db > def initialize( dblist ) @dbs = dblist > end > > @dbs.each do |cnt| # <= line producing the error > db_lbl = cnt[0] > db_nm = cnt[1] > end end > > %w(rubygems ruby-debug readline strscan logger fileutils).each{ |lib| > require lib } > Debugger.start > debugger # call to ruby-debug > > main # ...initiate execution (at this point all dependencies are resolved) > > # end file > ========= > > Error msg: setnet-xa.rb:12: undefined method `each' for nil:NilClass > (NoMethodError) > > It appears that @dbs is not getting initialized, but I cannot why not. > > Any help would be much appreciated! > > Tom > > -- > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist > Bellingham, Washington, U.S.A: (360) 920-1226 > << tc@tomcloyd.com >> (email) > << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental > health weblog) > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > -- xucros.com --0016369205b18a74fc04612c3bf7--