8 ms·
Some Amazon programmer tomorrow priceIncrease := (newPrice - oldPrice) / oldPrice var trump_tariff bool if priceIncrease > 1.0 { trump_tariff = true }
by maxvisser 1y ago
Some Amazon programmer tomorrow
priceIncrease := (newPrice - oldPrice) / oldPrice
var trump_tariff bool
if priceIncrease > 1.0 {
trump_tariff = true
}
- unwind 1y agoPlease don't use if:s to assign boolean literals, just do it: const trump_tariff = priceIncrease > 1.0 also saves you from not initializing the variable in the default/other case. :)
- throwaway519 1y agoconst I feel you may underestimate how often they change.
- Upvoter33 1y agoThis was just someone showing you what the "Amazon programmer" was doing, and hence a deep cut reference to the likelihood of it being poor quality code :)
- TheSoftwareGuy 1y agoIf you really wanted to look like Amazon codex you would write Java :)
- maxvisser 1y agoI see I missed an opportunity to make it even funnier.
- Someone 1y agoIn the original code, trump_tariff is a sticky value. If that’s intended/not intended, the above introduces/fixes a bug.
- grokkedit 1y agonot to mention the mix of snake_case & camelCase
- ImHereToVote 1y agoIf statements are great because they are highly readable.