Difference between !X(true) and X(false)

I haven't programmed for a while and recently used a sketch which contained this line:

if(!SPIFFS.begin(true)){..............

I thought, well now that's the same as:

if(SPIFFS.begin(false)){.....

But it isn't because the sketch using the second version doesn't work. Can someone refresh my memory on the difference between the two commands.

Does SPIFFS.begin() actually take a parameter and what does it return ?

Your if statements are testing the return value of the SPIFFS.begin function. The true and false are arguments passed to that function. To understand how the value of the argument affects the return value, you'd need to study the documentation or source code of that function. There certainly is no guarantee that inverting the Boolean value of the argument will also invert the return value, as you seem to expect.

You're probably thinking of this sort of syntax:

if(!SPIFFS.begin(something) == true){

which is equivalent to:

if(SPIFFS.begin(something) == false){

That is also equivalent to:

if(!SPIFFS.begin(something)){

likely the author of the code wrote it that way because it means less typing, even though it's a bit more obfuscated.

I thought, well now that's the same as

Sorry no it is not.

Sorry no it is not.

I know! I actually said so in the OP.

So do you understand why you were mistaken now?

So do you understand why you were mistaken now?

Of course, pert explained it very well.