From: Jonathan Nielsen Date: 2010-06-19T02:51:28+09:00 Subject: Re: String comparison. Why does Ruby consider this true? --00c09f93d5b0f43b4904895197b8 Content-Type: text/plain; charset=UTF-8 On Fri, Jun 18, 2010 at 11:46 AM, Abder-rahman Ali < abder.rahman.ali@gmail.com> wrote: > When I try for example to compare the following strings in Ruby, I get > "true". > > puts 'Xeo' < 'ball' > > When I make 'Xeo' start with a lowercase letter, i get 'false' > > puts 'xeo' < 'ball' > > The second statement is clear, but why when I capitalize 'Xeo' I get > true? > > Thanks. > -- > Posted via http://www.ruby-forum.com/. > > Because the '<' is doing a character-by-character compare on the strings. As it turns out, 'X' < 'b' is true, while 'x' < 'b' is false. This is because in the basic character set, the uppercase letters are lower-valued than lowercase letters. See http://www.asciitable.com/ -Jonathan Nielsen --00c09f93d5b0f43b4904895197b8--