[前][次][番号順一覧][スレッド一覧]

ruby-changes:71694

From: Burdette <ko1@a...>
Date: Tue, 12 Apr 2022 03:49:53 +0900 (JST)
Subject: [ruby-changes:71694] 7d709ceb12 (master): Specify which core classes are convertible (#5790)

https://git.ruby-lang.org/ruby.git/commit/?id=7d709ceb12

From 7d709ceb12259b2b863a4a1f484987840d174514 Mon Sep 17 00:00:00 2001
From: Burdette Lamar <BurdetteLamar@Y...>
Date: Mon, 11 Apr 2022 13:49:38 -0500
Subject: Specify which core classes are convertible (#5790)

---
 doc/implicit_conversion.rdoc | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/doc/implicit_conversion.rdoc b/doc/implicit_conversion.rdoc
index 0c2a1d4971..ba15fa4bf4 100644
--- a/doc/implicit_conversion.rdoc
+++ b/doc/implicit_conversion.rdoc
@@ -2,6 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/doc/implicit_conversion.rdoc#L2
 
 Some Ruby methods accept one or more objects
 that can be either:
+
 * <i>Of a given class</i>, and so accepted as is.
 * <i>Implicitly convertible to that class</i>, in which case
   the called method converts the object.
@@ -17,10 +18,15 @@ a specific conversion method: https://github.com/ruby/ruby/blob/trunk/doc/implicit_conversion.rdoc#L18
 === Array-Convertible Objects
 
 An <i>Array-convertible object</i> is an object that:
+
 * Has instance method +to_ary+.
 * The method accepts no arguments.
 * The method returns an object +obj+ for which <tt>obj.kind_of?(Array)</tt> returns +true+.
 
+The Ruby core class that satisfies these requirements is:
+
+* Array
+
 The examples in this section use method <tt>Array#replace</tt>,
 which accepts an Array-convertible argument.
 
@@ -66,10 +72,15 @@ This class is not Array-convertible (method +to_ary+ returns non-Array): https://github.com/ruby/ruby/blob/trunk/doc/implicit_conversion.rdoc#L72
 === Hash-Convertible Objects
 
 A <i>Hash-convertible object</i> is an object that:
+
 * Has instance method +to_hash+.
 * The method accepts no arguments.
 * The method returns an object +obj+ for which <tt>obj.kind_of?(Hash)</tt> returns +true+.
 
+The Ruby core class that satisfies these requirements is:
+
+* Hash
+
 The examples in this section use method <tt>Hash#merge</tt>,
 which accepts a Hash-convertible argument.
 
@@ -115,10 +126,18 @@ This class is not Hash-convertible (method +to_hash+ returns non-Hash): https://github.com/ruby/ruby/blob/trunk/doc/implicit_conversion.rdoc#L126
 === Integer-Convertible Objects
 
 An <i>Integer-convertible object</i> is an object that:
+
 * Has instance method +to_int+.
 * The method accepts no arguments.
 * The method returns an object +obj+ for which <tt>obj.kind_of?(Integer)</tt> returns +true+.
 
+The Ruby core classes that satisfy these requirements are:
+
+* Integer
+* Float
+* Complex
+* Rational
+
 The examples in this section use method <tt>Array.new</tt>,
 which accepts an Integer-convertible argument.
 
@@ -159,6 +178,10 @@ A <i>String-convertible object</i> is an object that: https://github.com/ruby/ruby/blob/trunk/doc/implicit_conversion.rdoc#L178
 * The method accepts no arguments.
 * The method returns an object +obj+ for which <tt>obj.kind_of?(String)</tt> returns +true+.
 
+The Ruby core class that satisfies these requirements is:
+
+* String
+
 The examples in this section use method <tt>String::new</tt>,
 which accepts a String-convertible argument.
 
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]