From: Paul Brannan Date: 2001-06-28T22:49:00+09:00 Subject: [ruby-talk:17007] Re: RCR for the String class > I don't know the rationale for the code rather than character > behavior, but perhaps someone who does will comment on it. I agree Well, I'm not certain what the exact reason is, but in C, a char *is* an integer, but with a smaller range than an int. In Ruby, it is the same way. If you ask for "foo"[0] then you get the character ?f. Since ?f is really just an integer, though, printing it out gives you a number. In C++, in order for cout << 'f' to print a letter, there is a distinction between a char and an int. It would be possible to make this distinction in Ruby and have a Character type that is basically just a Fixnum with to_s defined differently. But then there is the problem of what do you get with the following: puts ?A + ?A puts ?A + 1 puts ?A + 65000 puts ?A * 2 Here, ?A returns a Character and is the same as "A"[0]. In each of these cases, should the result be printed as a character or as an integer? Paul