What style should I chose?

What style should I chose?

if (this_variable) {
do.this();
}

or

if (this_variable == true) {
do.this();
}

first doesn't use redundant code but the second one looks easier to read. What style do you chose and why?

if ( this_variable && true)

I use "== true" on variables, and the first for functions.

this

>first doesn't use redundant code but the second one looks easier to read. What style do you chose and why?
you answered yourself
>second one looks easier to read
second

The first is the correct way. The second way is just for people who are learning. The suggestion listing both is redundant

>second one looks easier to read
Maybe you're using shitty variable naming?

if (hasExpired) {
doStuff();
}


is easier to read than

if (hasExpired == true) {
doStuff();
}

if ( ((char)this_variable != 0) == true )

Won't true always be true though?

Not if you code in PHP

this_variable ? do.this();

_self_.kill();

People reading the code should be aware of the type of your variable, and since it's a boolean, it doesn't really even make sense to compare it to true.

Also this helps

This man knows what's up. Good variable/method naming is 90% of what makes your code readable.

I'd always go with the first option, though any compiler that optimizes at all would treat both the same.

However, if the first style looks unclear you probably have a weird name. Booleans should be stuff like 'allowed' 'enabled' 'possible' anyways and "if (enabled)" shouldn't look weird.

if( this_variable == true && this_variable != false && !this_variable == true && this_variable ) {
do.this();
}

for(; this_variable; )
{
// ...
break;
}

switch(this_variable) {
true:
do_stuff();
}

Default state should be false.
Here is some examples
while ( !complete )
if( !out_of_range )
if( !no_errors )

second obviously
everyone saying otherwise is a fucking troll

>second
I meant first

fuck up that post really good

if (this_variable && this_variable == true)

That way people who write both types of code understand what you meant

I'd do second. I agree that while the part is redundant, the second makes it very apparent what it is and any pajeet will understand it.

A code monkey writes code that works. A good programmer can write code that anybody can understand.

It's why brackets are such a hot topic.

!(this.variable != !false)&&(
do.this();
)

Why stop at the second option?

if ((this_variable == true) == true)

if variable:
print('Hello')

vs

if variable is not None:
print('Hello')

Code is meant to be human readable, so second one is better

(!(!(if ((this_variable != !!false&&(return !false)) != !true)) ? :'')?return !eval(!true):return false)&&(do.this();)

(if this-variable (this do))

It's entirely dependent on how you name this_variable. If you have the name of your variables of the boolean type start with "is", like isOn or isValid, you should go with the first style because code is kept non-redundant with very little impact to readability.

This is the stupidest I have ever seen.
Whats the reason being redundant with your code?

false == true?

You couldn't even get your meme right.

if(this_variable.ToString().ToLower().BeginsWith("true"))
{
do.this();
}
else if(this_variable.ToString().ToLower().BeginsWith("false")
{
do.this();
}

》 still performs same method.

If the variable is properly named, first.

IF THIS_VARIABLE
PERFORM DOTHIS
ELSE
IF NOT THIS_VARIABLE
PERFORM DOTHAT
END-IF
END-IF.

Which language pussies?

1st checks boolean value of var so not only None will prevent the printing but also 0, [], (,), etc.

let a = '';
(Math.random() > 0.5)&&(a='!')
if (eval(a + 'this.variable')){
do.this();
}

lw $t0, this_variable
beq $t0, 1, do_this

Applescript?

I didn't realize metalheads went and made their own screaming language.

if (variable != 0x0) {
do shit
}

The second one my byutt

No it's COBOL.
This is literally how I program day in day out.

Honestly whichever one you prefer.
If you are more comfortable glancing at the first one and knowing it means it's true, use it. Same goes for the second.

Clean Code tends to disagree with you.

if (var){
do niggerdicks
}

if tab tab
for tab tab
dont forget your shortcuts up

!!!(!!!this_variable != !!!(!!!this_variable != ((!!!this_variable || (!!!false != !!!true) && !!!true)))) || do.this.faggot!();