{"id":581,"date":"2023-02-06T18:16:21","date_gmt":"2023-02-06T18:16:21","guid":{"rendered":"https:\/\/baldsolutions.com\/?p=581"},"modified":"2023-02-06T18:16:21","modified_gmt":"2023-02-06T18:16:21","slug":"simplify-the-if-statement","status":"publish","type":"post","link":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/","title":{"rendered":"Simplify the &#8220;if&#8221; statement"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This is probably the shortest post I&#8217;ve ever made but its content can simplify your <code>if<\/code> statements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As a developer of it is common to have  an <code>if<\/code> statement that checks if one exactly one of two conditions  is true. The first thought would be something like this: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if(condition1 &amp;&amp; !condition2 || !condition1 &amp;&amp; condition2)\n   ...<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">XOR operator<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">There is an operator named <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/csharp\/language-reference\/operators\/boolean-logical-operators#logical-exclusive-or-operator-\" target=\"_blank\" rel=\"noopener\" title=\"XOR\">XOR<\/a> and you probably know that.  I knew the XOR operator but didn&#8217;t use it in presented scenario. The if statement can be rewritten:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if(condition1 ^ condition2)\n   ... <\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Summary<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Have a nice day, bye!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is probably the shortest post I&#8217;ve ever made but its content can simplify your if statements. As a developer of it is common to&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/\">Continue reading<span class=\"screen-reader-text\">Simplify the &#8220;if&#8221; statement<\/span><\/a><\/div>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-581","post","type-post","status-publish","format-standard","hentry","category-net","entry"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"This is probably the shortest post I&#039;ve ever made but its content can simplify your if statements. As a developer of it is common to have an if statement that checks if one exactly one of two conditions is true. The first thought would be something like this: if(condition1 &amp;&amp; !condition2 || !condition1 &amp;&amp; condition2)\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Tomasz\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Bald Solutions -\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Simplify the \u201cif\u201d statement - Bald Solutions\" \/>\n\t\t<meta property=\"og:description\" content=\"This is probably the shortest post I&#039;ve ever made but its content can simplify your if statements. As a developer of it is common to have an if statement that checks if one exactly one of two conditions is true. The first thought would be something like this: if(condition1 &amp;&amp; !condition2 || !condition1 &amp;&amp; condition2)\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2023-02-06T18:16:21+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2023-02-06T18:16:21+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Simplify the \u201cif\u201d statement - Bald Solutions\" \/>\n\t\t<meta name=\"twitter:description\" content=\"This is probably the shortest post I&#039;ve ever made but its content can simplify your if statements. As a developer of it is common to have an if statement that checks if one exactly one of two conditions is true. The first thought would be something like this: if(condition1 &amp;&amp; !condition2 || !condition1 &amp;&amp; condition2)\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/2023\\\/02\\\/06\\\/simplify-the-if-statement\\\/#blogposting\",\"name\":\"Simplify the \\u201cif\\u201d statement - Bald Solutions\",\"headline\":\"Simplify the &#8220;if&#8221; statement\",\"author\":{\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/author\\\/tomasz3396\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/#organization\"},\"datePublished\":\"2023-02-06T18:16:21+00:00\",\"dateModified\":\"2023-02-06T18:16:21+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/2023\\\/02\\\/06\\\/simplify-the-if-statement\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/2023\\\/02\\\/06\\\/simplify-the-if-statement\\\/#webpage\"},\"articleSection\":\".NET\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/2023\\\/02\\\/06\\\/simplify-the-if-statement\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/baldsolutions.com#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/baldsolutions.com\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/category\\\/net\\\/#listItem\",\"name\":\".NET\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/category\\\/net\\\/#listItem\",\"position\":2,\"name\":\".NET\",\"item\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/category\\\/net\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/2023\\\/02\\\/06\\\/simplify-the-if-statement\\\/#listItem\",\"name\":\"Simplify the &#8220;if&#8221; statement\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/baldsolutions.com#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/2023\\\/02\\\/06\\\/simplify-the-if-statement\\\/#listItem\",\"position\":3,\"name\":\"Simplify the &#8220;if&#8221; statement\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/category\\\/net\\\/#listItem\",\"name\":\".NET\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/#organization\",\"name\":\"Bald Solutions\",\"url\":\"https:\\\/\\\/baldsolutions.com\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/author\\\/tomasz3396\\\/#author\",\"url\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/author\\\/tomasz3396\\\/\",\"name\":\"Tomasz\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/2023\\\/02\\\/06\\\/simplify-the-if-statement\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d72f2f7f389921b820e5ef7c2880172fc2b9ae47698a933356df224581de0cc7?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Tomasz\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/2023\\\/02\\\/06\\\/simplify-the-if-statement\\\/#webpage\",\"url\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/2023\\\/02\\\/06\\\/simplify-the-if-statement\\\/\",\"name\":\"Simplify the \\u201cif\\u201d statement - Bald Solutions\",\"description\":\"This is probably the shortest post I've ever made but its content can simplify your if statements. As a developer of it is common to have an if statement that checks if one exactly one of two conditions is true. The first thought would be something like this: if(condition1 && !condition2 || !condition1 && condition2)\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/2023\\\/02\\\/06\\\/simplify-the-if-statement\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/author\\\/tomasz3396\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/index.php\\\/author\\\/tomasz3396\\\/#author\"},\"datePublished\":\"2023-02-06T18:16:21+00:00\",\"dateModified\":\"2023-02-06T18:16:21+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/#website\",\"url\":\"https:\\\/\\\/baldsolutions.com\\\/\",\"name\":\"Bald Solutions\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/baldsolutions.com\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Simplify the \u201cif\u201d statement - Bald Solutions","description":"This is probably the shortest post I've ever made but its content can simplify your if statements. As a developer of it is common to have an if statement that checks if one exactly one of two conditions is true. The first thought would be something like this: if(condition1 && !condition2 || !condition1 && condition2)","canonical_url":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/#blogposting","name":"Simplify the \u201cif\u201d statement - Bald Solutions","headline":"Simplify the &#8220;if&#8221; statement","author":{"@id":"https:\/\/baldsolutions.com\/index.php\/author\/tomasz3396\/#author"},"publisher":{"@id":"https:\/\/baldsolutions.com\/#organization"},"datePublished":"2023-02-06T18:16:21+00:00","dateModified":"2023-02-06T18:16:21+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/#webpage"},"isPartOf":{"@id":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/#webpage"},"articleSection":".NET"},{"@type":"BreadcrumbList","@id":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/baldsolutions.com#listItem","position":1,"name":"Home","item":"https:\/\/baldsolutions.com","nextItem":{"@type":"ListItem","@id":"https:\/\/baldsolutions.com\/index.php\/category\/net\/#listItem","name":".NET"}},{"@type":"ListItem","@id":"https:\/\/baldsolutions.com\/index.php\/category\/net\/#listItem","position":2,"name":".NET","item":"https:\/\/baldsolutions.com\/index.php\/category\/net\/","nextItem":{"@type":"ListItem","@id":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/#listItem","name":"Simplify the &#8220;if&#8221; statement"},"previousItem":{"@type":"ListItem","@id":"https:\/\/baldsolutions.com#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/#listItem","position":3,"name":"Simplify the &#8220;if&#8221; statement","previousItem":{"@type":"ListItem","@id":"https:\/\/baldsolutions.com\/index.php\/category\/net\/#listItem","name":".NET"}}]},{"@type":"Organization","@id":"https:\/\/baldsolutions.com\/#organization","name":"Bald Solutions","url":"https:\/\/baldsolutions.com\/"},{"@type":"Person","@id":"https:\/\/baldsolutions.com\/index.php\/author\/tomasz3396\/#author","url":"https:\/\/baldsolutions.com\/index.php\/author\/tomasz3396\/","name":"Tomasz","image":{"@type":"ImageObject","@id":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/d72f2f7f389921b820e5ef7c2880172fc2b9ae47698a933356df224581de0cc7?s=96&d=mm&r=g","width":96,"height":96,"caption":"Tomasz"}},{"@type":"WebPage","@id":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/#webpage","url":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/","name":"Simplify the \u201cif\u201d statement - Bald Solutions","description":"This is probably the shortest post I've ever made but its content can simplify your if statements. As a developer of it is common to have an if statement that checks if one exactly one of two conditions is true. The first thought would be something like this: if(condition1 && !condition2 || !condition1 && condition2)","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/baldsolutions.com\/#website"},"breadcrumb":{"@id":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/#breadcrumblist"},"author":{"@id":"https:\/\/baldsolutions.com\/index.php\/author\/tomasz3396\/#author"},"creator":{"@id":"https:\/\/baldsolutions.com\/index.php\/author\/tomasz3396\/#author"},"datePublished":"2023-02-06T18:16:21+00:00","dateModified":"2023-02-06T18:16:21+00:00"},{"@type":"WebSite","@id":"https:\/\/baldsolutions.com\/#website","url":"https:\/\/baldsolutions.com\/","name":"Bald Solutions","inLanguage":"en-US","publisher":{"@id":"https:\/\/baldsolutions.com\/#organization"}}]},"og:locale":"en_US","og:site_name":"Bald Solutions -","og:type":"article","og:title":"Simplify the \u201cif\u201d statement - Bald Solutions","og:description":"This is probably the shortest post I've ever made but its content can simplify your if statements. As a developer of it is common to have an if statement that checks if one exactly one of two conditions is true. The first thought would be something like this: if(condition1 &amp;&amp; !condition2 || !condition1 &amp;&amp; condition2)","og:url":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/","article:published_time":"2023-02-06T18:16:21+00:00","article:modified_time":"2023-02-06T18:16:21+00:00","twitter:card":"summary","twitter:title":"Simplify the \u201cif\u201d statement - Bald Solutions","twitter:description":"This is probably the shortest post I've ever made but its content can simplify your if statements. As a developer of it is common to have an if statement that checks if one exactly one of two conditions is true. The first thought would be something like this: if(condition1 &amp;&amp; !condition2 || !condition1 &amp;&amp; condition2)"},"aioseo_meta_data":{"post_id":"581","title":null,"description":null,"keywords":[],"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2023-02-06 18:03:19","updated":"2025-06-04 05:28:42","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/baldsolutions.com\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/baldsolutions.com\/index.php\/category\/net\/\" title=\".NET\">.NET<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tSimplify the \u201cif\u201d statement\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/baldsolutions.com"},{"label":".NET","link":"https:\/\/baldsolutions.com\/index.php\/category\/net\/"},{"label":"Simplify the &#8220;if&#8221; statement","link":"https:\/\/baldsolutions.com\/index.php\/2023\/02\/06\/simplify-the-if-statement\/"}],"_links":{"self":[{"href":"https:\/\/baldsolutions.com\/index.php\/wp-json\/wp\/v2\/posts\/581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/baldsolutions.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/baldsolutions.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/baldsolutions.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/baldsolutions.com\/index.php\/wp-json\/wp\/v2\/comments?post=581"}],"version-history":[{"count":11,"href":"https:\/\/baldsolutions.com\/index.php\/wp-json\/wp\/v2\/posts\/581\/revisions"}],"predecessor-version":[{"id":592,"href":"https:\/\/baldsolutions.com\/index.php\/wp-json\/wp\/v2\/posts\/581\/revisions\/592"}],"wp:attachment":[{"href":"https:\/\/baldsolutions.com\/index.php\/wp-json\/wp\/v2\/media?parent=581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/baldsolutions.com\/index.php\/wp-json\/wp\/v2\/categories?post=581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/baldsolutions.com\/index.php\/wp-json\/wp\/v2\/tags?post=581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}