4 ms·
In the first place, a language that exposes pointers may not be able to do away with null. But as for languages like Java, the problem can be solved with the he
by vmathew 16y ago
In the first place, a language that exposes pointers may not be able to do away with null. But as for languages like Java, the problem can be solved with the help of an implicit, non-mutable default object:
Foo foo; // initialized to default
if (x) {
// stuff
foo = Foo.p1;
} else {
// stuff
foo = Foo.p2;
}
// No need to check if this is a valid reference, it always will be.
foo.bar();