Equality vs. Assignment

Random irrelevance that just didn't fit into other forums. Talk about anything.

Moderator: Talkative People

Post Reply
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Equality vs. Assignment

Post by dandymcgee »

So I'm feeling pretty damn awful today (some sort of throat cough) and I made literally the most elementary programming mistake in existence:

Image

I honestly can't remember the last time I wrote one equal sign instead of two.. it's been years. I'm pretty embarassed, but I blame it on my health.

So tell us, when's the last time you wrote '=' instead of '=='?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: Equality vs. Assignment

Post by bbguimaraes »

Image

Also, -Wparentheses, although I believe none of the are new to you.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Equality vs. Assignment

Post by dandymcgee »

The funniest part is this isn't my code base and I was trying to conform to someone else's style. I would *never* write "if(x == false)" in my own code, I'd just use "if(!x)".
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
superLED
Chaos Rift Junior
Chaos Rift Junior
Posts: 303
Joined: Sun Nov 21, 2010 10:56 am
Current Project: Engine
Favorite Gaming Platforms: N64
Programming Language of Choice: C++, PHP
Location: Norway

Re: Equality vs. Assignment

Post by superLED »

One time I was sick, I actually wrote if(x != true)

It's been a while since I wrote only one =, but when it happens, it takes forever to find the mistake, because who the fuck would think they wrote only one =? xD Always the last place I look.
zeroandnull
ES Beta Backer
ES Beta Backer
Posts: 4
Joined: Sun Jan 25, 2015 10:27 pm

Re: Equality vs. Assignment

Post by zeroandnull »

dandymcgee wrote:I would *never* write "if(x == false)" in my own code, I'd just use "if(!x)".
superLED wrote:One time I was sick, I actually wrote if(x != true)
At the end of the day it doesn't matter because your compiler will optimize away stuff like that.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Equality vs. Assignment

Post by dandymcgee »

zeroandnull wrote:
dandymcgee wrote:I would *never* write "if(x == false)" in my own code, I'd just use "if(!x)".
superLED wrote:One time I was sick, I actually wrote if(x != true)
At the end of the day it doesn't matter because your compiler will optimize away stuff like that.
It does matter, because on makes it easier to make the assignment mistake. Also, I had just gotten done updating some vb code.. and in vb a single '=' is the correct syntax. Ugh, I hate vb.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Post Reply