From: Chris Bailey Date: 2007-10-02T20:44:37+09:00 Subject: Variable scope in GServer ------=_NextPart_000_0128_01C804C8.116E9810 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable (Repost) Thank you for the correction Bertram, I've never used a mailing list = before and it didn't occur to me. Hopefully it's in the right place now. I'm having a bit of a problem accessing variables in an instance of = GServer. What I would like to do is make a hash that is effectively global to the current thread. -/Server.rb require 'gserver' require 'connect.rb' class TestServer < GServer def initialize(port =3D 4000, *args) super(port, *args) end def serve( io ) @test_hash =3D Hash.new connect(io) #Defined in connect.rb loop do str =3D io.gets parser(str,io) end end end The way that I'm doing it doesn't allow each thread to have it's own = copy of @test_hash and that's my problem. I need each thread to be able to = change the data stored in the hash without affecting the data stored in the = hash for all threads. I'm sure that my understanding of scope and GServer = itself is causing my problem, but I just don't know what to do to fix it. I was thinking that I could pass the hash as a parameter to the connect = function but that would quickly become a problem as it would need to be passed to several other functions after that and if possible I just don't want to = have to use that many extra parameters in my functions. Any help would be appreciated. ------=_NextPart_000_0128_01C804C8.116E9810--