mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add Symbol#name and freezing explanation to #to_s
This commit is contained in:
parent
4a18cc7f60
commit
4728c0d900
Notes:
git
2020-12-22 09:23:04 +09:00
1 changed files with 23 additions and 0 deletions
23
string.c
23
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.
|
||||
*/
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue