+ 8

please someone describe it.....

"Greater than and less than operators can also be used to compare strings lexicographically (the alphabetical order of words is based on the alphabetical order of their component letters)." What is this? How can I compare? What will be the output for certain comparisons? describe these exaples-- puts 'Hello world' > 'hello world' puts 'Hello world' < 'hello world' puts 'Hello world' == ' hello world'

29th Mar 2020, 10:51 AM
M Tamim
M Tamim - avatar
1 ответ
+ 2
I am not good in ruby but lexicography is common in most of programming languages The comparison is taken on the lexicographic order of the first character in the string Lexicography order is A, B, C.... Z, a, b, c... z In 'Hello world', the first character is 'H' and in 'hello world', first character is 'h' The uppercase 'H' comes before lowercase 'h' So the lexicographic order of 'h' is more than 'H' So puts 'Hello world' > 'hello world' Output: false puts 'Hello world' < 'hello world' output: true puts 'Hello world' == 'hello world' output: false
29th Mar 2020, 12:41 PM
Farhan
Farhan - avatar