by kierenj · 2y ago · 0 comments
var taxInvoice = false
var sendEmail = true
RaiseInvoice(taxInvoice, sendEmail)
It's obvious, but people tend not to do it. RaiseInvoice(/*taxInvoice*/ false, /*sendEmail*/ true)I don't know why more languages don't have named parameters...
// Booleans + Named Parameters
foo(should_scrub=not options.scrubbing_disabled)
// Single-Use Enum
import ScrubbingOption, ShouldScrub;
foo(
if options.scrubbing == ScrubbingOption::Disabled {
ShouldScrub::No
} else {
ShouldScrub::Yes
}
) foo(options.scrubbing == ScrubbingOption::Disabled ? ShouldScrub::No : ShouldScrub::Yes)
it doesn't look much worse at allThat doesn't fix the possibility of adding a third possibility either (what if we separate non-tax invoices into two types of invoices?).
RaiseInvoice(InvoiceType::Tax, Notifications::Email);