[DOC] Tweaks for rb_hash_s_try_convert
This commit is contained in:
parent
63b6323e04
commit
d3bb42776c
Notes:
git
2025-01-29 15:17:05 +00:00
Merged: https://github.com/ruby/ruby/pull/12632 Merged-By: peterzhu2118 <peter@peterzhu.ca>
13
hash.c
13
hash.c
@ -1902,16 +1902,15 @@ rb_check_hash_type(VALUE hash)
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* Hash.try_convert(obj) -> obj, new_hash, or nil
|
||||
* Hash.try_convert(object) -> object, new_hash, or nil
|
||||
*
|
||||
* If +obj+ is a +Hash+ object, returns +obj+.
|
||||
* If +object+ is a hash, returns +object+.
|
||||
*
|
||||
* Otherwise if +obj+ responds to <tt>:to_hash</tt>,
|
||||
* calls <tt>obj.to_hash</tt> and returns the result.
|
||||
* Otherwise if +object+ responds to +:to_hash+,
|
||||
* calls <tt>object.to_hash</tt>;
|
||||
* returns the result if it is a hash, or raises TypeError if not.
|
||||
*
|
||||
* Returns +nil+ if +obj+ does not respond to <tt>:to_hash</tt>
|
||||
*
|
||||
* Raises an exception unless <tt>obj.to_hash</tt> returns a +Hash+ object.
|
||||
* Otherwise if +object+ does not respond to +:to_hash+, returns +nil+.
|
||||
*/
|
||||
static VALUE
|
||||
rb_hash_s_try_convert(VALUE dummy, VALUE hash)
|
||||
|
Loading…
x
Reference in New Issue
Block a user