Equality vs. Assignment

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

Moderator: Talkative People

Equality vs. Assignment

Postby dandymcgee on Thu Apr 16, 2015 3:52 pm

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
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire

Re: Equality vs. Assignment

Postby bbguimaraes on Thu Apr 16, 2015 5:04 pm

Image

Also, -Wparentheses, although I believe none of the are new to you.
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
 
Posts: 324
Joined: Wed Apr 11, 2012 5:34 pm
Location: Brazil

Re: Equality vs. Assignment

Postby dandymcgee on Thu Apr 16, 2015 5:48 pm

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
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire

Re: Equality vs. Assignment

Postby superLED on Sat Apr 18, 2015 6:00 pm

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.
User avatar
superLED
Chaos Rift Junior
Chaos Rift Junior
 
Posts: 337
Joined: Sun Nov 21, 2010 12:56 pm
Location: Norway

Re: Equality vs. Assignment

Postby zeroandnull on Sat Apr 18, 2015 10:07 pm

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.
zeroandnull
ES Beta Backer
ES Beta Backer
 
Posts: 4
Joined: Mon Jan 26, 2015 12:27 am

Re: Equality vs. Assignment

Postby dandymcgee on Sat Apr 18, 2015 11:16 pm

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:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire


Return to General/Off-Topic

Who is online

Users browsing this forum: No registered users and 3 guests

cron