Actions
Bug #20606
closedThread#thread_variable_get, Thread#thread_variable? and Thread#[] methods handle non-String/Symbol parameter values differently
Bug #20606:
Thread#thread_variable_get, Thread#thread_variable? and Thread#[] methods handle non-String/Symbol parameter values differently
Description
The Thread#thread_variable_get, Thread#thread_variable? and Thread#[] methods handle the key parameter that is not a String or a Symbol in different way but I would expect them to be consistent and raise an exception.
When no thread-local variables were assigned to a thread the Thread#thread_variable_get and Thread#thread_variable? methods don't raise TypeError when argument is of incorrect type. But Thread#[] does raise TypeError exception:
t = Thread.new {}.join
puts t.thread_variable_get(123).inspect # nil
puts t.thread_variable?(123).inspect # false
t[123] # `[]': 123 is not a symbol nor a string (TypeError)
Actions