Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Hash.ruby2_keywords_hash?
Hash.ruby2_keywords_hash?(hash) → true or false
hash.c
View on GitHub ↗
static VALUE
rb_hash_s_ruby2_keywords_hash_p(VALUE dummy, VALUE hash)
{
Check_Type(hash, T_HASH);
return RBOOL(RHASH(hash)->basic.flags & RHASH_PASS_AS_KEYWORDS);
}
Deprecated: will be removed in Ruby 4.5, one version after the removal of the ruby2_keywords mechanism. See bugs.ruby-lang.org/issues/22205 for the schedule.
Checks if a given hash is flagged by Module#ruby2_keywords (or Proc#ruby2_keywords). This method is not for casual use; debugging, researching, and some truly necessary cases like serialization of arguments.
Example
ruby2_keywords def foo(*args) Hash.ruby2_keywords_hash?(args.last) end foo(k: 1) #=> true foo({k: 1}) #=> false
Ruby version changes
-
4.1
-
Hash.ruby2_keywords_hash?andHash.ruby2_keywords_hashare deprecated and will be removed in Ruby 4.5. [Feature #22205]
-