Issue #6697 has been updated by naruse (Yui NARUSE).

Status changed from Open to Feedback

String(obj) calls obj.to_str first, then calls obj.to_s.
So they are different.

Integer("foo") raises ArgumentError, but "foo".to_i returns 0.
Array("foo") returns ["foo"], but "foo".to_a raises NoMethodError on 1.9.
Hash(nil) returns {}, but nil.to_hash raises NoMethodError.

So your point about consistency is not reasonable.
----------------------------------------
Feature #6697: [PATCH] Add Kernel#Symbol conversion method like String(), Array() etc.
https://bugs.ruby-lang.org/issues/6697#change-27884

Author: madeofcode (Mark Dodwell)
Status: Feedback
Priority: Normal
Assignee: 
Category: 
Target version: 2.0.0


For consistency, it seems to make sense to add a Kernel#Symbol helper.

This change would not break any existing code and it provides a more consistent interface.

Thoughts?


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