Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Objects Encapsulation and Arrays Ternary If

Why is ( value < 0) not accepted on the code challenge while (value < 0) is accepted?

My first code on the Code challenge was: int value = -1; string textColor = null;

textColor = ( value < 0 ) ? "red" : "green";

however, the code challenge does not accepted it and returned "Bummer! Did you include the boolean expression to evaluate? "

however, upon removing the space (" ") and making the 3rd line: textColor = (value < 0 ) ? "red" : "green";

the code challenge accepted it.

Please enlighten us about this.

Thank you.

1 Answer

Steven Parker
Steven Parker
215,939 Points

You don't really need parentheses at all, but you're right that if you do have them the spacing should not matter.

While the forum is a great place to get help from other students, it may not be the most expedient (or even certain) way to contact the staff. You may also want to report this as a bug as described on the Support page.