aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-01-30 13:14:18 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2023-01-30 13:18:19 -0800
commit344c16eba40457f937c6558299f52bc97d6f3ce7 (patch)
tree049c01d81060a33f12d5f8fd59b7f8107f795433 /numeric.c
parent006682d3915ce065687c3d54a0b1eb91439b28e9 (diff)
downloadruby-344c16eba40457f937c6558299f52bc97d6f3ce7.tar.gz
Avoid using a weird syntax for documentation
Following up 465bd972ec2. If the actual implementation still resides in C, it should be documented in C just like all other places.
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index 15729e4728..d1316eb6e2 100644
--- a/numeric.c
+++ b/numeric.c
@@ -6008,7 +6008,22 @@ rb_int_s_isqrt(VALUE self, VALUE num)
}
}
-/* :nodoc: */
+/*
+ * call-seq:
+ * Integer.try_convert(object) -> object, integer, or nil
+ *
+ * If +object+ is an \Integer object, returns +object+.
+ * Integer.try_convert(1) # => 1
+ *
+ * Otherwise if +object+ responds to <tt>:to_int</tt>,
+ * calls <tt>object.to_int</tt> and returns the result.
+ * Integer.try_convert(1.25) # => 1
+ *
+ * Returns +nil+ if +object+ does not respond to <tt>:to_int</tt>
+ * Integer.try_convert([]) # => nil
+ *
+ * Raises an exception unless <tt>object.to_int</tt> returns an \Integer object.
+ */
static VALUE
int_s_try_convert(VALUE self, VALUE num)
{