Sep-10-2019, 04:09 PM
I prefer the first. It makes it clear that the value is relevant outside of the if-block, whereas if it exists entirely indented, it appears at a glance as if it's not relevant outside that block.
Or the ternary version if it's simple. But if it isn't simple, it should probably be pulled out into it's own function anyway (something like lookup_location_name).
Or the ternary version if it's simple. But if it isn't simple, it should probably be pulled out into it's own function anyway (something like lookup_location_name).