On 5/16/07, dblack / wobblini.net <dblack / wobblini.net> wrote:
> Hi --
>
> On Wed, 16 May 2007, Logan Capaldo wrote:
>
> > On 5/16/07, Trans <transfire / gmail.com> wrote:
> >>
> >>
> >> On May 16, 5:44 am, "Sven Suska (enduro)" <sven71... / suska.org> wrote:
> >> > Subclassing alone would not be enough, to solve the problem above,
> >> > also, String#== and Symbol#== would have to be defined such that  "a" ==
> >> :a
> >> > And also #hash would have to be defined accordingly.
> >> >
> >> > Then you would still have the two different kinds of objects ("a" and :a)
> >> > but they would behave quite the same  except for modifying methods.
> >>
> >> While I think Symbol probably could use at least few of String's
> >> manipulation methods, putting that aside, I wonder how it would effect
> >> things just to make :a == "a" ?
> >>
> > Well there is precendent, 2 == 2.0 and so on
>
> With symbols being as integer-like as they are string-like, though,
> it's really equally similar to:
>
>    2 == :"2"
>
I don't think symbols are integer like. (I don't know that they are
especially string like either), but I'd be willing to bet a lot more
code in the wild would be broken if you removed Symbol#to_s vs.
removing Symbol#to_i.

Your example really ought to be

2 == :whatever_symbol_whose_to_i_results_in_2


>
> David
>
> --
> Q. What is THE Ruby book for Rails developers?
> A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
>     (See what readers are saying!  http://www.rubypal.com/r4rrevs.pdf)
> Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
> A. Ruby Power and Light, LLC (http://www.rubypal.com)
>
>