summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorzverok <zverok.offline@gmail.com>2020-12-17 00:49:52 +0200
committerMarc-André Lafortune <github@marc-andre.ca>2020-12-21 19:22:38 -0500
commit4728c0d900f40036757d869fd5f20673c563bac7 (patch)
tree44d7b71906dfa07ba2d55eb905e75a22b9c544ac /string.c
parent4a18cc7f604c259415d933acd9fd00234733cab6 (diff)
Add Symbol#name and freezing explanation to #to_s
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3966
Diffstat (limited to 'string.c')
-rw-r--r--string.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/string.c b/string.c
index 3dab48c701..2a95a8357c 100644
--- a/string.c
+++ b/string.c
@@ -11052,6 +11052,26 @@ sym_inspect(VALUE sym)
return str;
}
+#if 0 /* for RDoc */
+/*
+ * call-seq:
+ * sym.name -> string
+ *
+ * Returns the name or string corresponding to <i>sym</i>. Unlike #to_s, the
+ * returned string is frozen.
+ *
+ * :fred.name #=> "fred"
+ * :fred.name.frozen? #=> true
+ * :fred.to_s #=> "fred"
+ * :fred.to_s.frozen? #=> false
+ */
+VALUE
+rb_sym2str(VALUE sym)
+{
+
+}
+#endif
+
/*
* call-seq:
@@ -11062,6 +11082,9 @@ sym_inspect(VALUE sym)
*
* :fred.id2name #=> "fred"
* :ginger.to_s #=> "ginger"
+ *
+ * Note that this string is not frozen (unlike the symbol itself).
+ * To get a frozen string, use #name.
*/