Tag Info

New answers tagged

2

The Python language is strongly influenced by C. And C is a horrible language that didn't even have a boolean type until C99. Instead, it has integers. Anything that looks like a zero integer is false, anything else is true. It turns out that this is mightily convenient. Wanna test for a null pointer? Unlike Java, you don't have to spell out if (thing != ...


-1

Why do all objects other than ones explicitly defined as False or "False" evaluate truthfully? Simple explanation: Because they do, by definition. Sorry if that seems like a tautology, but that really is the correct answer: this is the arbitrary way it works because that is the arbitrary way it is specified to work in the arbitrary, canonical rules of ...


1

At first glance, your 'clear' approach does look compact and clean, but if you were to unravel the statements... // PHP? public function effective() { $nonGroup = !$this->org->isGroup(); $hasParent = false; if ($nonGroup) { $hasParent = ($parent = $this->org->getParentOrg()) instanceof OrgModel; } $inherits = false; ...


3

This seems to disregard the nice and simple: return complicated_test_1() && complicated_test_2() && complicated_test_3(); This is certainly simpler than either of your options, and I assume you rejected it because: the complicated_test are not single function calls, but themselves Boolean expressions But this is a self-inflicted ...


1

There is some ambiguity with the term "preconditions": it could mean "do not call the function if these are not valid" (that is, something that client code should handle) it could mean "if these are not valid in the function, (log message and) compute nothing" it could mean "if these are not valid exit the application" When implementing this, you should ...



Top 50 recent answers are included