Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7188749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:09:08+00:00 2026-05-28T19:09:08+00:00

There was a bug report Pathname#to_str doesn’t appear to work anymore . Having to_str

  • 0

There was a bug report Pathname#to_str doesn’t appear to work anymore. Having to_str in Pathname would let you use Pathname anywhere you use a string, eg with Dir, system, etc. However the bug report was rejected, and it appears from a commit message that the to_str method was deliberately removed.

I don’t understand this – Pathname can be loselessly converted to a String and back, and it would be very convenient when working with APIs that don’t use Pathname.

So why is having to_str not appropriate for Pathname, and when is to_str okay to use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:09:09+00:00Added an answer on May 28, 2026 at 7:09 pm

    Here’s an article that attempts to answer your question but, in my opinion, doesn’t really succeed.

    Around the same time Pathname#to_str was removed Exception#to_str was removed as well–clearly Matz was trying to draw a line in the sand at this time between “stringlike” and “non-stringlike” classes. The Exception change makes sense–an Exception cannot, to use your words, “be losslessly converted to a String and back,” because an Exception object contains lots of other information–the stack trace in particular–that would be lost in that conversion.

    I can only guess but I’d wager that Matz felt the same way about Pathname, though it’s unclear why. Even to documentation (1.9.3) at one point, says (under “Core methods”), “These methods are effectively manipulating a String, because that’s all a path is.” Several sources I’ve found–in addition to the one @MarkThomas cites–use Pathname as an example of a class for which to_str does make sense, probably taking a cue from Hal Fulton’s The Ruby Way.

    I guess this isn’t a very satisfactory answer. If you really want to know you may have to ask on Ruby-Talk or Ruby-Core. You could try asking Matz [on Twitter](Yukihiro Matsumoto), but he seems to converse exclusively in Japanese. Wycats and Jeremy Kemper may have some more insight, though, and seem pretty accessible. Good luck!

    P.S. This article has a section “Technical explanation of to_str and friends” that I found interesting, but it doesn’t do any better a job of answering your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like my program to email me a bug-report when it fails. Is
Is there a Subversion host that: lets end-users file bug reports arranges bug reports/customer
I came across an issue that makes me think there is bug in the
Is there any good bug tracker based on .NET which is free?
I assumed there were only bug fixes/(no new types) in .NET 2.0 SP1 until
It seems to be well-known there is a bug when using JMenuItem.getRootPane(). I read
I have developed an AJAX based game where there is a bug caused (very
Just flicking through one of my favourite books (Ellen Ullman's The Bug) and there
While using fixed width select tag , there is one bug in IE. When
There seems to be a bug in a Wordpress PHP function that leaves whitespace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.