Created
July 26, 2012 05:56
-
-
Save mstrobel/3180488 to your computer and use it in GitHub Desktop.
So much evil...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Evil | |
{ | |
internal static class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
Evil x; | |
MoreEvil y; | |
// Prints True, False | |
Console.WriteLine(x == true ? true : false); | |
Console.WriteLine(x ? true : false); | |
// Prints False, True | |
Console.WriteLine(y == true ? true : false); | |
Console.WriteLine(y ? true : false); | |
} | |
} | |
public struct Evil | |
{ | |
public static bool operator true(Evil x) | |
{ | |
return false; | |
} | |
public static bool operator false(Evil x) | |
{ | |
return true; | |
} | |
public static bool operator ==(Evil x, bool y) | |
{ | |
return true; | |
} | |
public static bool operator !=(Evil x, bool y) | |
{ | |
return false; | |
} | |
} | |
public struct MoreEvil | |
{ | |
public static Evil operator ==(MoreEvil x, bool y) | |
{ | |
return default(Evil); | |
} | |
public static Evil operator !=(MoreEvil x, bool y) | |
{ | |
return default(Evil); | |
} | |
public static bool operator true(MoreEvil x) | |
{ | |
return true; | |
} | |
public static bool operator false(MoreEvil x) | |
{ | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment