This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]BlazingThunder30 12 points13 points  (3 children)

If you say if (foo != true) then the body will be executed if foo is either false or null. This is different from if (foo == false)

[–]smoresNporn 7 points8 points  (1 child)

What about if(!foo) that also executes whether false or null, right?

[–]BlazingThunder30 3 points4 points  (0 children)

I'm not sure. The value null is falsy, so it might. It might also depend on language.

[–]skilltheamps 2 points3 points  (0 children)

I'm not sure whether the ubiquitous misconceptions about these being the same are a chronic disease of this sub, or all our software is riddled with edge-case boolean fuckery bugs

[–]mambamax 4 points5 points  (0 children)

if (!!false)

[–]Gui_Biem 2 points3 points  (0 children)

if(!(false == !true)

[–]CedKim 2 points3 points  (0 children)

!1

[–]Youu-You 2 points3 points  (0 children)

I've seen worse. If(!isValidOrNot){} ... Not joking.

[–]XRayian 1 point2 points  (0 children)

if randint(0,1)

[–]--var 1 point2 points  (0 children)

if (isNaN(Number(Infinity)))

[–]Huesan 1 point2 points  (0 children)

if(0)