Project

General

Profile

Feature #16985

Updated by Eregon (Benoit Daloze) over 4 years ago

Could we improve `pp` for `Hash` and `String`: 

 ```ruby 
 pp({hello: 'My name is "Marc-André"'}) 
 # => 
 {hello: 'My name is "Marc-André"'} "Marc-André"}  
 # instead of 
 {:hello=>"My name is \"Marc-André\""} 
 ``` 

 If any key is non-symbol, they would continue to be output as `<key> => <value>`. 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?)

Back