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 trialsergio verdeza
Courses Plus Student 10,765 PointsWrite the Ruby code to check if the variable "a" is greater than the variable "b".
Ruby Operators using the greater than sign
This is the answer I'm writing on the code but is not correct even though I'm checking the correct answer the treehouse workspace?
"a" > "b"
The answer is false but I'm not sure what is not accepting my code?
Any help will be greatly appreciated, thank you.
10 Answers
J Scott Erickson
11,883 PointsYou don't need the quotes. This makes the comparison happen on the string literals "a" and "b"
a > b
Wendel Ferreira
4,258 PointsI got confused here as well!
Cara Hill
2,859 PointsI was confused as well - we used the quotes in the example in the video!
Mary Dickson
7,293 PointsIt's so frustrating to not have a hint here... I got confused with this as well. Would be nice to have a "reveal answer" option to move forward.
sergio verdeza
Courses Plus Student 10,765 PointsWOW!!! Thank you Scott :)
Hunter Rancourt
3,485 PointsJust curious, in a real code situation wouldn't we need the quotes because we did not define what variables a and b are equal to?
J Scott Erickson
11,883 PointsWell, operation under the assumption that variables a and b exist wrapping them in quotes would never actually compare the values in the variables.
And comparing "a" > "b" is akin to writing the bool false. So I can't think off the top of my head where that would necessarily be useful.
William Lynch
5,636 Pointsok, I figured it out. It was worth pursuing. You have to have a space before and after the operator.
I tried these on the challenge and got:
a>b fails a > b works.
Bill
nlitwin
3,505 PointsThere's no reason for the quotes in the question. It should read: "Write the Ruby code to check if the variable a is greater than the variable b." "a" implies that it's a string.
Austin Lyons
7,172 PointsI also go confused....even rewatched the examples over and over again...the answer needs to be fixed to match the video.