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

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
231,198 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.