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

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
215,372 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;