Skip to content

Instantly share code, notes, and snippets.

@jbevain
Created October 20, 2016 22:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jbevain/8b10f1ee73ead7161ac5b1b2d9005287 to your computer and use it in GitHub Desktop.
Save jbevain/8b10f1ee73ead7161ac5b1b2d9005287 to your computer and use it in GitHub Desktop.
using System;
struct Vector3
{
public float X, Y, Z;
public static bool operator true(Vector3 v)
{
return v.X != 0 && v.Y != 0 && v.Z != 0;
}
public static bool operator false(Vector3 v)
{
return v.X == 0 && v.Y == 0 && v.Z == 0;
}
public static bool operator !(Vector3 v)
{
return v.X == 0 && v.Y == 0 && v.Z == 0;
}
}
class Program
{
static void Main(string[] args)
{
var id = new Vector3 { X = 1, Y = 1, Z = 1 };
var zero = new Vector3();
if (id) Console.WriteLine("id is true");
if (!zero) Console.WriteLine("zero is false");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment