diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-10-05 00:52:32 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-10-05 15:13:55 +0900 |
| commit | 4ddbee33097c431e83d4dbc6a130349067bf7c0a (patch) | |
| tree | 8f96ec2b1b7a0a32c349e9b7fdcada1a2a158e5b | |
| parent | 4b50d0b41cc0a4c808d0d128e7068e4b3b9331bf (diff) | |
[ruby/pp] Refine `Set#pretty_print` check
https://github.com/ruby/pp/commit/6615b62d7b
| -rw-r--r-- | lib/pp.rb | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -443,6 +443,13 @@ class Hash # :nodoc: end end +if defined?(Set) + if set_pp = Set.instance_method(:initialize).source_location + set_pp = !set_pp.first.end_with?("/set.rb") # not defined in set.rb + else + set_pp = true # defined in C + end +end class Set # :nodoc: def pretty_print(pp) # :nodoc: pp.group(1, '#<Set:', '>') { @@ -453,12 +460,12 @@ class Set # :nodoc: } } } - end unless method_defined?(:pretty_print) + end def pretty_print_cycle(pp) # :nodoc: pp.text sprintf('#<Set: {%s}>', empty? ? '' : '...') - end unless method_defined?(:pretty_print_cycle) -end + end +end if set_pp class << ENV # :nodoc: def pretty_print(q) # :nodoc: |
