summaryrefslogtreecommitdiff
path: root/symbol.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2024-01-31 07:47:35 -0800
committerGitHub <noreply@github.com>2024-01-31 10:47:35 -0500
commit51753ec7fa82fb5c3f7ef3c5766b0e84c47d3d21 (patch)
treec1f71e8039dac2dfc52280e2af7fb7c1fbf097f8 /symbol.rb
parenta322b2faa40959ffdbe6da077c778131cb1c894f (diff)
Annotate Symbol#to_s as leaf (#9769)
Diffstat (limited to 'symbol.rb')
-rw-r--r--symbol.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/symbol.rb b/symbol.rb
index f31bf0bee3..bfac11ae21 100644
--- a/symbol.rb
+++ b/symbol.rb
@@ -1,5 +1,20 @@
class Symbol
# call-seq:
+ # to_s -> string
+ #
+ # Returns a string representation of +self+ (not including the leading colon):
+ #
+ # :foo.to_s # => "foo"
+ #
+ # Related: Symbol#inspect, Symbol#name.
+ def to_s
+ Primitive.attr! :leaf
+ Primitive.cexpr! 'rb_sym_to_s(self)'
+ end
+
+ alias id2name to_s
+
+ # call-seq:
# to_sym -> self
#
# Returns +self+.