From: "David A. Black" Date: 2007-03-09T07:10:03+09:00 Subject: Re: Paul Graham explains Ruby symbols Hi -- On 3/8/07, Rick DeNatale wrote: > On 3/8/07, David A. Black wrote: > > Hi -- > > > > On 3/8/07, Gary Wright wrote: > > > > > > On Mar 8, 2007, at 12:41 AM, Chad Perrin wrote: > > > > Obviously, a symbol is different in easily explained ways from string > > > > variables, without having to drag implementation into it. Things > > > > aren't > > > > quite so clear-cut between symbols and string *literals*, though. > > > > > > I'm not sure that the problem you are describing has anything to do with > > > symbols. Anyone learning Ruby is going to have to understand the > > > difference between "1", 1, 1.0, /1/, and :1. Symbol literals > > > aren't really special in this regard. > > > > I'll add yet another way of thinking about symbols, namely that they > > are very integer-like. All of the immutable, unique, immediate-value > > stuff is not so much a modification of how strings behave as a rather > > exact replication of how integers behave. > > As Obi-wan Kenobi would say, "that's (only) true from a certain point of view." > > irb(main):002:0> :a + :b > NoMethodError: undefined method `+' for :a:Symbol > from (irb):2 > > ;-) Sure, though it's no more specifically a limitation of the integer-like point than the string-like point :-) 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)