class method
Hash.try_convert
[U, V] (::_ToHash[U, V]) -> ::Hash[U, V]
(untyped) -> (::Hash[untyped, untyped] | nil)
Hash.try_convert(object) → object, new_hash, or nil
hash.c
View on GitHub ↗
static VALUE
rb_hash_s_try_convert(VALUE dummy, VALUE hash)
{
return rb_check_hash_type(hash);
}
If object is a hash, returns object.
Otherwise if object responds to :to_hash, calls object.to_hash; returns the result if it is a hash, or raises TypeError if not.
Otherwise if object does not respond to :to_hash, returns nil.
See also
.ruby2_keywords_hash?
#<
.ruby2_keywords_hash
#<=
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0