Actions
Bug #16906
closedCalling Thread#thread_variable? in IRB sometimes produce wrong result
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin17]
Description
Consider this script:
Thread.current.thread_variable_set("ab", 12)
puts Thread.current.thread_variable?("ab")
puts Thread.current.thread_variable?(:ab)
puts Thread.current.thread_variable?("ab")
When I put the script above in a file and run it, I got three true
as expected:
bash-3.2$ ruby test.rb
true
true
true
But when I copy each line to IRB, I got false on the first check:
bash-3.2$ irb
irb(main):001:0> Thread.current.thread_variable_set("ab", 12)
=> 12
irb(main):002:0> puts Thread.current.thread_variable?("ab")
false
=> nil
irb(main):003:0> puts Thread.current.thread_variable?(:ab)
true
=> nil
irb(main):004:0> puts Thread.current.thread_variable?("ab")
true
=> nil
I expect it to print three true
in IRB, just like when I run the script via file.
Files
Actions
Like0
Like0Like0Like0Like0