if 1=1? WHY?

  • (2 Pages)
  • +
  • 1
  • 2

29 Replies - 3428 Views - Last Post: 05 June 2013 - 12:45 PM Rate Topic: -----

#1 mb2000inc  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 354
  • Joined: 10-November 09

if 1=1? WHY?

Posted 17 May 2013 - 09:31 AM

I inherited a really complex project at work that kept breaking... on the following line(s) of code:

if(1 = 1)
{
  //...do some more code
}
else if(1 = 2)
{
  //...more code stuff
}
else
{
  return 1;
}



I think this wins the internet.
Is This A Good Question/Topic? 0
  • +

Replies To: if 1=1? WHY?

#2 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7895
  • View blog
  • Posts: 13,424
  • Joined: 19-March 11

Re: if 1=1? WHY?

Posted 17 May 2013 - 09:41 AM

I see this kind of thing periodically. It's usually an alternative to commenting out code while you're trying stuff. Usually don't see three branches of it though.
Was This Post Helpful? 1
  • +
  • -

#3 mb2000inc  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 354
  • Joined: 10-November 09

Re: if 1=1? WHY?

Posted 17 May 2013 - 09:43 AM

Shoot! This sucker was running in PRODUCTION on a highly client visible site that kept bombing out and no one knew why...
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9426
  • View blog
  • Posts: 35,422
  • Joined: 12-June 08

Re: if 1=1? WHY?

Posted 17 May 2013 - 09:47 AM

Are you sure those are 1's and not l's?
Was This Post Helpful? 1
  • +
  • -

#5 mb2000inc  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 354
  • Joined: 10-November 09

Re: if 1=1? WHY?

Posted 17 May 2013 - 10:12 AM

Oh, I'm sure. There's no "l" variables or anything of the sort.
Straight up Integers. (no quotation marks ;) )
Was This Post Helpful? 0
  • +
  • -

#6 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 492
  • View blog
  • Posts: 3,271
  • Joined: 12-January 10

Re: if 1=1? WHY?

Posted 17 May 2013 - 12:26 PM

sure they arent lower case L
Was This Post Helpful? 1
  • +
  • -

#7 mb2000inc  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 354
  • Joined: 10-November 09

Re: if 1=1? WHY?

Posted 17 May 2013 - 01:09 PM

I'm sure. I copied the code right from visual studio. and there are no "quotes" around the character, indicating a string, nor were there any variables declared in the script with single letters.
Was This Post Helpful? 0
  • +
  • -

#8 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3642
  • View blog
  • Posts: 12,635
  • Joined: 12-December 12

Re: if 1=1? WHY?

Posted 17 May 2013 - 01:18 PM

Perhaps there is some quantum tunnelling involved :dontgetit:
Was This Post Helpful? 1
  • +
  • -

#9 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7895
  • View blog
  • Posts: 13,424
  • Joined: 19-March 11

Re: if 1=1? WHY?

Posted 17 May 2013 - 01:32 PM

View Postandrewsw, on 17 May 2013 - 03:18 PM, said:

Perhaps there is some quantum tunnelling stupid involved :dontgetit:/>


FTFY
Was This Post Helpful? 0
  • +
  • -

#10 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3642
  • View blog
  • Posts: 12,635
  • Joined: 12-December 12

Re: if 1=1? WHY?

Posted 17 May 2013 - 01:43 PM

:offtopic: When I first started out there was no such thing as a debugger. My program wasn't working and I printed it out to several arms length of (dot-matrix) print. It took me a week to discover that I had an l which should have been 1 :surrender:. However, I believe I learnt so much during the search that has stood me in good stead ever since. I can (almost) spot errors at ten paces :)
Was This Post Helpful? 4
  • +
  • -

#11 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7895
  • View blog
  • Posts: 13,424
  • Joined: 19-March 11

Re: if 1=1? WHY?

Posted 17 May 2013 - 01:48 PM

That bug is immortalized in pbl's sig:

http://www.dreaminco...have-ever-seen/
Was This Post Helpful? 1
  • +
  • -

#12 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5365
  • View blog
  • Posts: 27,329
  • Joined: 10-May 07

Re: if 1=1? WHY?

Posted 17 May 2013 - 01:49 PM

Double positives?
Was This Post Helpful? 1
  • +
  • -

#13 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3642
  • View blog
  • Posts: 12,635
  • Joined: 12-December 12

Re: if 1=1? WHY?

Posted 17 May 2013 - 01:58 PM

Binary should have been defined in terms of X and Z (not Y, it's too similar to X) - there is no reason why 1s and 0s had to be used.

BTW Is there a circumstance where 1 != +(+1) ?

This post has been edited by andrewsw: 17 May 2013 - 02:01 PM

Was This Post Helpful? 1
  • +
  • -

#14 mb2000inc  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 354
  • Joined: 10-November 09

Re: if 1=1? WHY?

Posted 17 May 2013 - 02:08 PM

I will say this, though... It works on my machine.

Posted Image
Was This Post Helpful? 0
  • +
  • -

#15 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9426
  • View blog
  • Posts: 35,422
  • Joined: 12-June 08

Re: if 1=1? WHY?

Posted 17 May 2013 - 02:10 PM

View Postno2pencil, on 17 May 2013 - 03:49 PM, said:

Double positives?

Just like my ST(u)Ds test!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2