From: zverok.offline@...
Date: 2020-10-02T09:22:15+00:00
Subject: [ruby-core:100278] [Ruby master Feature#17210] More readable and	useful `Set#inspect`

Issue #17210 has been updated by zverok (Victor Shepelev).


BTW, as a side note, it would be good to have some "style guide" for inspect behavior in Ruby. Ad-hoc rule seem to be `#<ClassName some representation of content>` most of the time, except for objects that have corresponding literals -- they are just represented by literals. But:
* how the "content" should be represented, is not always consistent from class to class: ` #<struct A a=1, b=2>`, `#<Date: 2020-10-02 ((2459125j,0s,0n),+0s,2299161j)>`, `#<Set: {1, 2, 3}>`, `#<OpenStruct a=1, b=2>`, `#<Enumerator: [1, 2, 3]:map>`, `<File:README.md>`, `#<CSV::Row "Name":"Bob" "Department":"Engineering" "Salary":"1000">`
* of core objects, say, the `Time` is breaking all conventions being represented as `2020-10-02 12:10:51 +0300` -- which even doesn't look as one atomic entity
* of all stdlib I've checked, only `matrix` does similar to proposed: `Matrix[[25, 93], [-1, 66]]`, `Vector[1, 2]`, so it is a bit unusual for `#inspect`, though it is not necessary a bad thng

----------------------------------------
Feature #17210: More readable and useful `Set#inspect`
https://bugs.ruby-lang.org/issues/17210#change-87865

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
----------------------------------------
I would like to change `Set#inspect`/`to_s`:

```ruby
# before
puts Set[1,2,3] # => "#<Set: {1, 2, 3}>"

# after
puts Set[1,2,3] # => "Set[1, 2, 3]"
```

This output is shorter, readable, and has the property that it corresponds to Ruby code



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>