Jim J's co-worker showed him this little snippet in the codebase.

foreach (ToolStripMenuItem item in documentMenuItem.DropDownItems) { item.Enabled = item.Enabled ? Document.Status == DocumentStatusConsts.New : item.Enabled; }

Tracing through the ternary, if the menu item is currently enabled, set it enabled if the document in question is new, otherwise set it to itself (that is to say, disabled).

Or, to put it differently, if it's not enabled, make sure it's not enabled.

My suspicion is that the original developer just really wanted to use a ternary, even if it didn't make much sense.

Jim writes:

When one of my colleagues showed me his find I suggested him to add this line into the loop: if (!item.Enabled) item.Enabled = false || item.Enabled;

Just to be absolutely sure the item will be disabled.

[Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. Get started with Otter today!