Closed ChrisMissal closed 11 years ago
If you're trying to make it a "fluent interface" I'd prefer the last example. However, "Or" implies some type of conditional statement to invoke the "Or" path, like an out-of-range configuration value.
Personally I find the "Or" syntax vague for default or fallback values. Consider:
config.RetryAttempts.DefaultTo(5);
or
config.DefaultTo(5).RetryAttempts();
I'm a bit on the fence about this feature because you could simple do this as:
config.RetryAttempts ?? 5;
It's already built into the language so adding something like .DefaultsTo()
would basically be that one line.
Not enough interest
Instead of using:
for a fallback default, consider:
or
I'm not sure which I like more.