Mega Code Archive

 
Categories / Ruby / Threads
 

True local variables (not accessible from outside)

thread = Thread.new do   t = Thread.current   t["var3"] = 25   t[:var4] = "foobar"   var3 = 99            # True local variables (not accessible from outside)   var4 = "zorch"        end a = thread[:var3]      # 25 b = thread["var4"]     # "foobar"