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

ruby-changes:64438

From: zverok <ko1@a...>
Date: Tue, 22 Dec 2020 09:22:59 +0900 (JST)
Subject: [ruby-changes:64438] 4728c0d900 (master): Add Symbol#name and freezing explanation to #to_s

https://git.ruby-lang.org/ruby.git/commit/?id=4728c0d900

From 4728c0d900f40036757d869fd5f20673c563bac7 Mon Sep 17 00:00:00 2001
From: zverok <zverok.offline@g...>
Date: Thu, 17 Dec 2020 00:49:52 +0200
Subject: Add Symbol#name and freezing explanation to #to_s


diff --git a/string.c b/string.c
index 3dab48c..2a95a83 100644
--- a/string.c
+++ b/string.c
@@ -11052,6 +11052,26 @@ sym_inspect(VALUE sym) https://github.com/ruby/ruby/blob/trunk/string.c#L11052
     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) https://github.com/ruby/ruby/blob/trunk/string.c#L11082
  *
  *     :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.
  */
 
 
-- 
cgit v0.10.2


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

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