summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2023-11-30 17:10:40 +0100
committergit <svn-admin@ruby-lang.org>2024-01-11 13:44:01 +0000
commit1ed3b6037566cef3d56e882eb0fcf1b14553f540 (patch)
tree0aff22917c79cb6dd5e475dcb59050fd4a257953 /lib
parent62382a434561b6fe56d479b8800cf6ccf017463c (diff)
[ruby/pp] Fix pretty printing a Data subclass instance when the subclass is anonymous
* It would be "#<data a=42>" (double space) instead of "#<data a=42>" (like #inspect). https://github.com/ruby/pp/commit/bed72bfcb8
Diffstat (limited to 'lib')
-rw-r--r--lib/pp.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/pp.rb b/lib/pp.rb
index 5e5fd06cae..fb7aa7b41c 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -422,7 +422,9 @@ end
class Data # :nodoc:
def pretty_print(q) # :nodoc:
- q.group(1, sprintf("#<data %s", PP.mcall(self, Kernel, :class).name), '>') {
+ class_name = PP.mcall(self, Kernel, :class).name
+ class_name = " #{class_name}" if class_name
+ q.group(1, "#<data#{class_name}", '>') {
q.seplist(PP.mcall(self, Kernel, :class).members, lambda { q.text "," }) {|member|
q.breakable
q.text member.to_s