I'm having trouble simplifying this logic of conditional statements. Is there a more effervescent way to write this?
if(($x || $a) && ($x || $y)) { if($x){ return true; } } return false;
if ($x) return true; return false;
According to your statement, you return true only if it $xis true, so is this the only statement that you really need to check, correct? Variables $aand $yhave no value.
$x
$a
$y
Edit: Same as:
return (bool) $x;
If you return true only if $ x is true, then the rest of the code does not matter. In this way,
EDIT: Oops... bool - , .
if, ($x || $a) && ($x || $y) $x || ($a && $y). , $x ( if), ($x || ($a && $y)) && $x. $x && $x || $x && $a && $y, $x || $x && $a && $y. OR $x . $x , .
if
($x || $a) && ($x || $y)
$x || ($a && $y)
($x || ($a && $y)) && $x
$x && $x || $x && $a && $y
$x || $x && $a && $y
, true, $x:
, $x. , :
return $x
if($x){ return true; } return false;
?
Edit:
if($x && ($a || $y)) return true; return false;
if(($x && $a && $y) { return true; } return false;
EDIT: return $x;
return $x;
You can write this as a single line expression ...
regardless of $ a and $ y, $ x must be true to return true
Source: https://habr.com/ru/post/1736443/More articles:Intel MKL memory and exception management - c ++Problem with .NET settings. Settings.Reload () and Settings.Save () not loading - c #Expander autocomplete in text field without using webservice - .netnew line of line in code - c #phpunit and autoloader - phphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1736444/recommend-a-better-way-to-turn-synchronous-methods-to-asynchronous-in-java&usg=ALkJrhjIJwPAnvfsbLYH5BBvtyVabPnmLgAdding a allocator to a C ++ class template to create a shared memory object - c ++what is the deal with estimating the compilation time of constant arithmetic, and can this be done in the preprocessor? - c ++Aggregating schedule data by start and end time - sqlHow can I send two messages through javamail so that Outlook can put them in the same conversation? - javaAll Articles