I wonder if there is a way to verify that the method input is correct? I understand that I can easily do this later and throw an error, but it would be nice if the compile time were caught.
Instead
CursorPosition(int x, int y)
{
if (x >= 80) { Console.WriteLine("off screen"); }
if (y >= 24) { Console.WriteLine("off screen"); }
}
Can't I just do it here, and compile the compiler and the error?
CursorPosition(int x < 80, y < 24)
{
// do stuff
}
Many thanks!
source
share