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

I can't get the Ternary If code challenge to work - "Boolean expression to evaluate."

I can't get the answer to the Ternary If code challenge. Each time I try something it returns "Did you include the Boolean expression to evaluate." I have tried many different variation of the boolean to get this to work. Each time I am confident and the error persists. Am I just misunderstanding the task or am I doing something completely wrong.

I have stared at it so much by this point that I fear I can't see the wood for the trees and am missing something very basic.

Thanks for the help.

1 Answer

Steven Parker
Steven Parker
229,744 Points

You forgot to show your code, but I can give you some hints based on what other students have done in the past. The most common issue with the ternary is attempting to use it to control program flow to assignment statements, like the original "if" does.

The entire ternary is an expression. So it would not normally contain assignment statements, though it's common for it to be used in one.

A typical use of a ternary might have a structure like this:

somevariable = conditional_expression ? value_if_true : value_if_false;