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.
request
Important
GetCost()
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.
Ahh I see, cheers for that. I'm beginning to regret using the embarrassing technique of using the audience as the debugger.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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 notImportant
, has no discount, and is not a member. The initialGetCost()
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.
Ahh I see, cheers for that. I'm beginning to regret using the embarrassing technique of using the audience as the debugger.