key?(p1)
public
Returns true if the given string (or symbol) exists as a
fiber-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_check_id(&key);
GetThreadPtr(self, th);
if (!id || !th->local_storage) {
return Qfalse;
}
if (st_lookup(th->local_storage, id, 0)) {
return Qtrue;
}
return Qfalse;
}