Posted November 19, 2016
Bookwyrm627: Why wouldn't your java compiler allow that to compile? "something" will be initialized by the incoming argument when the method is called, so it has an int value for the while comparison and walkroads (assuming it exists and takes two ints for arguments) should be called on each while interation.
If you tried to call meaning with something besides an int, then the compiler still wouldn't trip over this method because the method signature would indicate some other method named "meaning" should be called.
Alaric.us: Yea, that code seems like it should be able to compile. If, when running it, you screw up and try executing meaning without giving it an int that it expects, only then should it error out. If you tried to call meaning with something besides an int, then the compiler still wouldn't trip over this method because the method signature would indicate some other method named "meaning" should be called.
I guess all languages and all compilers are different in how they handle things.
Kind of like ... people on a forum. o_O
But yeah, probably there will be warnings, errors or possible uninitiated values no matter what compiler you're using. But because you pass a basic type, there has to be a value assigned to it, and you imply the evaluation in the loop is valid. If it's an object class, and it has evaluation methods for the object declared and implemented, that then you can use in these checks, and so on, you end up being able to tell at compiletime if the check is valid.
Really neat stuff. So you could create an object that must be inside valid ranges based on some criteria you set, for example. Whether you use enums or just make something from scratch, seems to work well. And then the compiler stops you from allowing a possible fail condition like this, was the point :p
This.. still is a sort of metaphor for the forum rules, isn't it..