key?(p1)
public
Returns true if the given string (or symbol) exists as a thread-local
variable.
me = Thread.current
me[:oliver] = "a"
me.key?(:oliver)
me.key?(:stanley)
Show source
static VALUE
rb_thread_key_p(VALUE self, VALUE key)
{
rb_thread_t *th;
ID id = rb_to_id(key);
GetThreadPtr(self, th);
if (!th->local_storage) {
return Qfalse;
}
if (st_lookup(th->local_storage, id, 0)) {
return Qtrue;
}
return Qfalse;
}