DEV Community

Discussion on: Don't ALWAYS quick-return from functions

Collapse
 
shalvah profile image
Shalvah • Edited

Yes. But I should point out that your final code snippet and the initial one may not do the same thing.

Sppose the request is not Important, has no discount, and is not a member. The initial GetCost() will return 20; the final one will return 12.

The only way for the two to be exactly identical in function is if certain conditions are mutually exclusive, but that isn't stated anywhere.

Thread Thread
 
benwinding profile image
Ben Winding

Ahh I see, cheers for that. I'm beginning to regret using the embarrassing technique of using the audience as the debugger.