From: "David A. Black" Date: 2005-02-03T13:01:36+09:00 Subject: Re: symbols vs strings vs ? --927295978-833990945-1107403279=:11773 Content-Type: MULTIPART/MIXED; BOUNDARY="927295978-833990945-1107403279=:11773" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --927295978-833990945-1107403279=:11773 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Thu, 3 Feb 2005, E S wrote: >> L=E4hett=E4j=E4: James Edward Gray II >> Aihe: Re: symbols vs strings vs ? >> >> On Feb 2, 2005, at 7:53 PM, E S wrote: >> >>> Always use a Symbol rather than a String, except if you >>> need to be able to print the string to file/screen/etc. >> >> Hmm, don't think I agree with that. What it you need to modify its >> contents? What if you want to use some of String's many helper >> methods? > > The way I thought of it is that if you need to modify a string, > it's a string that is going to displayed somehow at some point. > > For the sake of disambiguity, however, let's amend that to > "Always use a Symbol rather than a constant String..." I don't think this rigid a distinction really works out in practice. For example, let's say you read a string from a file, and then do some match operations on it. They don't modify the string (it's constant), but it's a bit roundabout to do: sym =3D file_handle.gets.intern if /xyz/.match(sym.to_s) ... David --=20 David A. Black dblack@wobblini.net --927295978-833990945-1107403279=:11773-- --927295978-833990945-1107403279=:11773--