From: zverok.offline@... Date: 2016-09-26T14:17:16+00:00 Subject: [ruby-core:77408] [Ruby trunk Misc#12790] Better inspect for stdlib classes Issue #12790 has been reported by Victor Shepelev. ---------------------------------------- Misc #12790: Better inspect for stdlib classes https://bugs.ruby-lang.org/issues/12790 * Author: Victor Shepelev * Status: Open * Priority: Normal * Assignee: ---------------------------------------- `#inspect` is important for understanding "what I have" in irb/pry, and in [puts-debugging](https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html), and in ton of other cases. Sadly, some of important stdlib classes (in my opinion) fail to provide concise and readable representation for `#inspect`. Some examples below: **BigDecimal** (important for representing money values, for example) Current behavior: ```ruby # # ^ ^ ^ ^ # 1 2 3 4 ``` 1. OK, this is reasonable 2. Do we really need object id here? As far as I can understand, developer is typically concerned only about numeric value identity, not object identity for bigdecimals. 3. OK, I understand about scientific representation, but it is hard to read (at least for me), and also single quotes around add to a confusion. 4. I'm not sure. Number of significant digits it is. So, what are the situation when you need to look at it constantly?.. So, ideal behavior: ```ruby # # or, preserving num. of sig.dig. # # ...or something like this # But for really large numbers it is still # ``` Side note: try to guess what `BigDecimal.new(2)**10_000` looks like?.. And whether this look is really useful for anything. **Date** and **DateTime** ```ruby Date.today # => # DateTime.now # => # ``` Maybe it is just me, but it does not look like part in parenthises (and double parenthises!) contain information of such real importance that it can change our perception of "what's going on"?.. If you work with current dates, it is just unnecessary; if you work with some really complicated historical dates, it is not enough, being too concise and enigmatic to give some understanding of epochs and calendars. (And to add, it is awfully inconsistent with Time's `#inspect`, which does provide just `2016-09-26 17:03:59 +0300`.) -- https://bugs.ruby-lang.org/ Unsubscribe: