Skip to content
REPORTWIRE NEWSROOM
Breaking
Humor

True Parseimony

True Parseimony

[ad_1]

We’ve seen this pattern many times here:

return (someCondition) ? true : false;

or

if (someCondition)
{
  return true;
}
else
{
  return false;
}

There are many variations on it, all of which highlight someone’s misunderstanding of boolean expressions. Today Kerry sends us a “fun” little twist, in C#.

return (someCondition || someOtherCondition) ? Boolean.Parse("true") : Boolean.Parse("false");

The conditions have been elided by Kerry, but they’re long and complicated, rendering the statement less readable than it appears here.

But here we’ve taken the “if-condition-return-condition” pattern and added needless string parsing to it.

[Advertisement]
Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.

[ad_2]

Remy Porter

Source link

ReportWire

ReportWire newsroom contributor.

Related Stories

Humor

We are plot armored.

[ad_1] We are plot armored. [ad_2] noreply@funnyjunk.com (beboba) Source link

Humor

Here we go

[ad_1] Tags: Gina valentina 2728 points, 142 comments. [ad_2] Source link