Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Operators and Control Structures Ruby Operators Greater Than

Lisa Rosselli
Lisa Rosselli
790 Points

"a" > "b" is a valid comparison, why does the interpreter (here) tell me it's not?

Given "Write the Ruby code to check if the variable "a" is greater than the variable "b"." In my Terminal's irb "a" > "b" is a valid comparison and returns false. Am I crazy?

"a".ord > "b".ord

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Lisa and Welcome to Treehouse.

I'm not sure why you are using .ord in the comparison? But aside from that, the challenge wants you to compare the variables a & b. Your code (minus the .ord) is comparing the strings a & b.

Get rid of the quotes and the .ord and you will be good to go.

a > b

Keep Coding! :)