From: Rik Hemsley Date: 2002-04-10T11:15:27+09:00 Subject: Re: Easy character comparisons #if Sean O'Dell > Today I spent a little time debugging something I "didn't expect." I > evaluated (using if) string[index] against a single character in a string > and for awhile, I couldn't figure out why it wasn't working. Then I > realized that string[index] returns a number, not a string containing a > single character. Example: > > "string"[0] == "s" => false > > I ended up having to change the expression to something like this: > > "string"[0..0] == "s" => true > > Is there a more elegant way of doing this sort of comparison? My fudged > way seems awkward. How's this ? "string"[0] == ?s => true I hate the syntax, but that's just the way it is. Rik