ScottPletcher - Tuesday, February 27, 2018 9:16 AM
Hi Scott,
Thanks for your comments!
My function gets the correct age, but I agree, there will always be one-off business rules to be applied. In your leap-year example, the age would not be augmented, instead, the rule would be applied outside the function. For example, a jurisdiction such as you mentioned would not alter a subjects age, but they might allow the subject to buy beer at 20 if non-leap year, and date is Feb 28, and subject DOB is Feb 29. Heck, I could pass a law that grants you the grandpa discount if your dog has pups, but that wouldn't actually make you a grandpa - and your subject is still 20 on Feb 28.
I agree, the variable is not needed. More of a style issue where I normally use vars to standardize return values across functions. You might be surprised, but benchmarks won't improve measurably by removing this var. Note, this is not interpreted code.