This is expected,
t = Thread.new{
Thread.current[:rabbit] = 'white'
}
##### t[:rabbit] = white
But I can't understand this:
class Whatever
def initialize
@thd = Thread.new{
Thread.current[:apple] = 'whatever'
}
end
def apple
@thd[:apple]
end
def thd
@thd
end
end
I want to access these, why are they nil?
Whatever.new.apple # nil
Whatever.new.thd[:apple] # nil
Whatever.new.thd.thread_variable_get(:apple) # nil
Why does this happen? How can I access @thd Thread variables?