From: marcandre-ruby-core@... Date: 2020-06-26T01:44:12+00:00 Subject: [ruby-core:98944] [Ruby master Feature#16985] Improve `pp` for `Hash` and `String` Issue #16985 has been updated by marcandre (Marc-Andre Lafortune). For `String`, I meant to say that current format would be kept the same except if the single quote version exist and has no escape. ```ruby pp "Hello" # => "Hello" (no change) pp "Won't\nwork \"Marc-Andr�\"" => "Won't\nwork \"Marc-Andr�\"" (no change) pp "Hello \"Marc-Andr�\"" # => 'Hello "Marc-Andr�"' (simpler version) ``` ---------------------------------------- Feature #16985: Improve `pp` for `Hash` and `String` https://bugs.ruby-lang.org/issues/16985#change-86319 * 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: