Issue #7849 has been updated by drbrain (Eric Hodel).


The purpose of to_str, to_int, to_ary and to_sym are to convert string, integer, array and symbol representations to objects of that class.

For example:

The rope data structure (which supports insertion, deletion and random access) can be used to implement a representation of a ruby string so it would be a good candidate for to_str.

A linked-list implementation could be a good candidate for to_ary

A roman numeral implementation that does not descend from Numeric represents an integer and would be a good candidate for to_int

A string can be used as an identifier (as in rake) so it has to_sym.

A symbol, being an identifier alone is not anything like a String.
----------------------------------------
Feature #7849: Symbol#to_str
https://bugs.ruby-lang.org/issues/7849#change-36326

Author: trans (Thomas Sawyer)
Status: Rejected
Priority: Normal
Assignee: 
Category: core
Target version: next minor


Even though a Symbol is not technically an honest-to-goodness String, from the standpoint of simple practicality it would help to have Symbol#to_str defined.

There are times when we want an argument to accept a String or a Symbol, but don't really want it to accept any type of object under the sun that responds to #to_s --which is just about anything. This is especially the case when writing DSLs. Having Symbol#to_str is the nice solution to this.

Defining Symbol#to_str may be an exception to the rule, but it's one worth making.



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