From: sawadatsuyoshi@... Date: 2020-06-26T06:01:06+00:00 Subject: [ruby-core:98946] [Ruby master Feature#16985] Improve `pp` for `Hash` and `String` Issue #16985 has been updated by sawa (Tsuyoshi Sawada). shyouhei (Shyouhei Urabe) wrote in #note-4: > There are lots of debatable points on String#inspect (for instance its return value depends on runtime locale, why?). Improving it can quite easily jump into a bikeshed. You might want to separate Hash's and String's discussions and focus on the Hash side, because almost nobody would against that part I guess. Actually, the issue on hash and that on string are related. If a symbol key needs quotation, should that be single quotes or double quotes? ```ruby # => {'3': 1} # => {"3": 1} ``` And as for me, I am rather against the proposal here regarding hash, but not so much on string. ---------------------------------------- Feature #16985: Improve `pp` for `Hash` and `String` https://bugs.ruby-lang.org/issues/16985#change-86322 * Author: marcandre (Marc-Andre Lafortune) * Status: Open * Priority: Normal * Assignee: akr (Akira Tanaka) ---------------------------------------- Could we improve `pp` for `Hash` and `String`: ```ruby pp({hello: 'My name is "Marc-Andr�"'}) # => {hello: 'My name is "Marc-Andr�"'} # instead of {:hello=>"My name is \"Marc-Andr�\""} ``` If any key is non-symbol, they would continue to be output as ` => `. If a string contains single quotes, or characters that need escaping (e.g. `"\n"`), current format would be used. I'll gladly provide a PR if this is deemed acceptable. I would even like this for `String#inspect` and `Hash#inspect` but it's not clear if this could lead to much incompatibility (maybe test suites?) -- https://bugs.ruby-lang.org/ Unsubscribe: