Sorry for the vague title, but I don’t even know how to describe it in a few words. The following pseudo code describes the problem.
new_res = some_fn()
res = some_condition(res, new_res) ? new_res : res
In short, I need to determine if I should set a variable to the new result or not, based on some condition.
Of course, the above code pattern works, but it seems to contain unnecessary repetition. Both res
and new_res
appear 3 times. Is there a better way to deal with this situation, other than writing a macro?
Thanks.