Missed Opportunity for Easter Egg
-
AspDotNetDev wrote:
If 1 = 2 Then
In old-school Fortran this was a real potential. Certain integers were stored at memory locations, then you could say 1 = 2 (assign the value 2 to where the value 1 is stored). Then statements like
if 1 = 2 then ...
would be 'valid'.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von BraunOh yes! I remember making that mistake - it took ages to find before I realized that my constant values had changed... Trouble was,
1=2
looked a lot like
I=2
:doh:
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
Pfft, what an idiot. We all know msdn recommends using 23 = 33, or even 23 = 12. http://msdn.microsoft.com/en-us/library/215yacb6(v=vs.71).aspx[^]
-
Pfft, what an idiot. We all know msdn recommends using 23 = 33, or even 23 = 12. http://msdn.microsoft.com/en-us/library/215yacb6(v=vs.71).aspx[^]
I thought MSDN recommended:
if (23 == 023)
{
...
}Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
I just came across this code written by a coworker:
If 1 = 2 Then
Seems silly; probably a way to temporarily block out some code or something of that sort. However, it made me wonder why there aren't more people taking advantage of a potential easter egg. When I typed in "2+2" into Google and WolframAlpha, they both replied with "4". :((
-
if (1 == 2)
{
throw new UniverseBorkedException("you're pretty much f***ed elephanted.");
}ha ha. Make it on production and guaranteed next day customers will call u ... ;)
-
I just came across this code written by a coworker:
If 1 = 2 Then
Seems silly; probably a way to temporarily block out some code or something of that sort. However, it made me wonder why there aren't more people taking advantage of a potential easter egg. When I typed in "2+2" into Google and WolframAlpha, they both replied with "4". :((
When I first read this, I assumed it was "ell" = 2 :doh:
Steve _________________ I C(++) therefore I am
-
Oh yes! I remember making that mistake - it took ages to find before I realized that my constant values had changed... Trouble was,
1=2
looked a lot like
I=2
:doh:
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
I've unwillingly sent millions of $ to my private bank account because O looked a lot like 0! Well, that's what I'll tell the judge when they find out ;p
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
if (1 == 2)
{
throw new UniverseBorkedException("you're pretty much f***ed elephanted.");
}Not f***ed, but rather elephanted or maybe pachydermed. Cheers!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
Me, 2012-05-24
-
Not f***ed, but rather elephanted or maybe pachydermed. Cheers!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
Me, 2012-05-24
-
Pfft, what an idiot. We all know msdn recommends using 23 = 33, or even 23 = 12. http://msdn.microsoft.com/en-us/library/215yacb6(v=vs.71).aspx[^]
or 9 x 6 = 42
-
In VB that expression will always resolve to False In other languages (C included) you could overload the values for 1 and 2 and/or the operator = or command If Good luck figuring out whats going on with that level of obfuscation. Its not something I would expect to see as a simple expression but it can be useful as a clause especially if you need to build up a complex expression at run time. In practice its more likely that some piece of funcionality is wanted to remain in the codebase but not required to run under normal circumstances - probably debug code although there are better ways of doing it.
-
In VB that expression will always resolve to False In other languages (C included) you could overload the values for 1 and 2 and/or the operator = or command If Good luck figuring out whats going on with that level of obfuscation. Its not something I would expect to see as a simple expression but it can be useful as a clause especially if you need to build up a complex expression at run time. In practice its more likely that some piece of funcionality is wanted to remain in the codebase but not required to run under normal circumstances - probably debug code although there are better ways of doing it.
greldak wrote:
In other languages (C included) you could overload the values for 1 and 2 and/or the operator = or command If
Good luck figuring out whats going on with that level of obfuscation.I'm pretty sure you're wrong about being able to override either the values or the operator in C (or even C++ for that matter), but I'd welcome a working example.
-
or 9 x 6 = 42
-
I just came across this code written by a coworker:
If 1 = 2 Then
Seems silly; probably a way to temporarily block out some code or something of that sort. However, it made me wonder why there aren't more people taking advantage of a potential easter egg. When I typed in "2+2" into Google and WolframAlpha, they both replied with "4". :((
-
Oh yes! I remember making that mistake - it took ages to find before I realized that my constant values had changed... Trouble was,
1=2
looked a lot like
I=2
:doh:
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
OriginalGriff wrote:
... my constant values had changed...
Something about that just doesn't seem right ...
-
AspDotNetDev wrote:
If 1 = 2 Then
In old-school Fortran this was a real potential. Certain integers were stored at memory locations, then you could say 1 = 2 (assign the value 2 to where the value 1 is stored). Then statements like
if 1 = 2 then ...
would be 'valid'.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun -
OriginalGriff wrote:
... my constant values had changed...
Something about that just doesn't seem right ...
That's why it took so long to work it out - it's just not something you expect... :laugh:
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
Neat trick. :thumbsup:
-
greldak wrote:
In other languages (C included) you could overload the values for 1 and 2 and/or the operator = or command If
Good luck figuring out whats going on with that level of obfuscation.I'm pretty sure you're wrong about being able to override either the values or the operator in C (or even C++ for that matter), but I'd welcome a working example.
compiles on GCC
#define if(X) if(1)
using namespace std;
int main()
{
if (1 == 2) {
cout << "this is executed" << endl;
}
return 0;
}this would compile on C compiler too, but I just hate using those printfs. But you were right about #defining numbers -- it's impossible. A define identifier name cannot start with a number. But you can overload almost anything else.
-
compiles on GCC
#define if(X) if(1)
using namespace std;
int main()
{
if (1 == 2) {
cout << "this is executed" << endl;
}
return 0;
}this would compile on C compiler too, but I just hate using those printfs. But you were right about #defining numbers -- it's impossible. A define identifier name cannot start with a number. But you can overload almost anything else.