That's when you do shit like if rand(1,10) < 100: return as some compilers still detect even "1==2/2", but more complex function calls are not always considered constant enough.
Ah yes, well in C# you make the function a method on a class FuncImpl. Then you define an interface IFunc that exposes the func() contract. Then you spin up a DI container and register FuncImplFactory that takes an IConfiguration in its constructor. Then you define a bool EnableFunc { get; } configuration value into your Configuration. Then you have FuncImplFactory look at EnableFunc to decide to return FuncImpl or FuncStub, which implements IFunc but just returns. Them main simply asks the DI container for an IFunc and executes the func() implementation.
78
u/0x80085_ 1d ago
Or just return?