From: Chris Thiel Date: 2007-08-15T00:50:37+09:00 Subject: Re: change of Symbol to respond to intern? ------=_Part_44606_4399025.1187106621267 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/14/07, thomas.macklin@gmail.com wrote: > > I often find myself writing methods with the following form: > > def foo(sym_or_str) > @iv = sym_or_str > end > > when I go to compare later vs @iv, I can do: > > def compare_vs_iv(arg) > if arg.to_s == @iv.to_s then > ... > end > ... > end > > but I can't do: > > if arg.intern == @iv.intern then > ... > end > > This is because symbols don't respond to intern. Is there any good > reason Symbol doesn't respond to intern, while String responds to > to_s, Array responds, to to_a, etc.? If not, I would like to propose > that the intern method be added to Symbol at some point. > > Thoughts? > > > Not sure of the differences (if any) between #intern and #to_sym, but symbols will respond to #to_sym and just return self. If there aren't any differences between #intern and #to_sym, I'd agree, #intern should be added to Symbol. Chris ------=_Part_44606_4399025.1187106621267--