Why do it the easy way?

Started by
11 comments, last by Sik_the_hedgehog 11 years, 1 month ago

Was gonna comment on the original topic, but what the— Abbreviations gone awry o_O And this is why you should avoid abbreviations except for a few well-estabilished ones...

As for the original topic, I find this a lot (and yes, with basic types, not classes which could have side-effects):

if (!blah)
   blah = true;

This could have easily done the job:

blah = true;
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
Advertisement

Was gonna comment on the original topic, but what the— Abbreviations gone awry o_O And this is why you should avoid abbreviations except for a few well-estabilished ones...

As for the original topic, I find this a lot (and yes, with basic types, not classes which could have side-effects):


if (!blah)
   blah = true;

This could have easily done the job:


blah = true;

Unless it is dynamically typed language (like javascript):


var blah = "hello";
if (!blah)
    blah = true;

// blah remains "hello"

blah = 15;
if (!blah)
    blah = true;

// blah remains 15

blah = 0;
if (!blah)
    blah = true;

// blah is true 

I hate dynamically typed languages for allowing this.

The examples of that I see are usually in C or C++ though...

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

This topic is closed to new replies.

Advertisement