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)
{
ID id = rb_check_id(&key);
st_table *local_storage = rb_thread_ptr(self)->ec->local_storage;
if (!id || local_storage == NULL) {
return Qfalse;
}
else if (st_lookup(local_storage, id, 0)) {
return Qtrue;
}
else {
return Qfalse;
}
}