T
trans. (T. Onoma)
If String has #to_sym wouldn't it make sense for Symbol to have #to_str ?
T.
T.
If String has #to_sym wouldn't it make sense for Symbol to have #to_str ?
Quoteing (e-mail address removed), on Tue, Nov 30, 2004 at 11:17:26AM +0900:
I think the relationship would be:
String#to_sym, ..#to_s, ..#to_i, #to_a
are all at the same level.
They are all methods on types that can be converted to the target, but
are not ALREADY of the type of the target of the conversion.
The next level is:
#to_str, #to_ary, #to_int all are supported by classes that ARE of that
type (in the duck-type sense).
That list could include #to_symbol... except there is nothing in ruby
that IS a symbol, only symbols are symbols.
My way of looking at it anyhow...
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.