I have the following code
test[variable_: 0] := Module[{},
If[variable != True, Print["worked"]];
];
test2[variable_: 0] := Module[{},
If[variable == True, Print["worked"]];
];
If I run
test2[True]
I get "worked" as I expect.
But if I run
test[]
I return nothing. Why is this the case?
==can't say anything about the equivalence between 0 andTrue. You want=!=and===instead. – C. E. Jul 05 '18 at 23:11TrueQ– b3m2a1 Jul 05 '18 at 23:150!=Trueand/or0==Trueand see what happens – yosimitsu kodanuri Jul 06 '18 at 06:41