Recently submitted an issue regarding to_str method on builtin types. The feedback I got was that we have Str.inspect at home. The reason I wanted to_str is that it's hard to chain inspect because it's on Str type rather than the type of the type I'm actually using.
That's a valid point! @Richard Feldman is probably the person who is most aware of all the trade-offs here.
you can do ->Str.inspect to chain it!
TIL
nandi has marked this topic as resolved.
Richard Feldman said:
you can do
->Str.inspectto chain it!
Perhaps .to_str would be worth it because it is easier to discover?
I should probably write about this somewhere, but philosophically the idea behind this design is:
Str.inspect accepts any type and does that, without anyone needing to do anythingStr.inspect, there's a method you can opt into defining to do thatto_strwhich is how you get things like end users seeing null or undefined rendered to them :sweat_smile:
Try shouldn't have a "display to end users" method, but it should have a "turn into a string for debugging/logging purposes"
and if it had to_str, it would be easy for end users to accidentally see Ok displayed to them
nandi has marked this topic as unresolved.
nandi has marked this topic as resolved.
Last updated: Jun 16 2026 at 16:19 UTC