(non)nullable types
Christopher Wright
dhasenan at gmail.com
Sat Feb 14 15:22:17 PST 2009
Nick Sabalausky wrote:
> You would only need to check when you're going to derefernce or convert to a
> non-nullable. Nulls could still be stored and passed around without
> checking. If this doesn't cover what you're concerned about, perhaps you
> could provide an example?
Let's say I originally have this:
class Foo {
void delegate()? dg;
void doStuff() {
if (dg) {
// some long code path with code duplicated from
// other methods in Foo
} else {
// some other long code path
}
}
}
Now I want to refactor that:
class Foo {
void delegate()? dg;
void doStuff() {
if (dg) {
doPart1;
doPart2;
} else {
// some other long code path
}
}
private void doPart1() {
// use dg; why should I check?
}
private void doPart2() {
// use dg; why should I check?
}
}
Small examples don't show it very well.
More information about the Digitalmars-d
mailing list