top | item 43831319 (no title) maxvisser | 10 months ago Some Amazon programmer tomorrowpriceIncrease := (newPrice - oldPrice) / oldPrice var trump_tariff boolif priceIncrease > 1.0 { trump_tariff = true } discuss order hn newest unwind|10 months ago Please 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. :) Upvoter33|10 months ago This 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 :) load replies (1) throwaway519|10 months ago const I feel you may underestimate how often they change. grokkedit|10 months ago not to mention the mix of snake_case & camelCase Someone|10 months ago In the original code, trump_tariff is a sticky value. If that’s intended/not intended, the above introduces/fixes a bug. ImHereToVote|10 months ago If statements are great because they are highly readable.
unwind|10 months ago Please 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. :) Upvoter33|10 months ago This 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 :) load replies (1) throwaway519|10 months ago const I feel you may underestimate how often they change. grokkedit|10 months ago not to mention the mix of snake_case & camelCase Someone|10 months ago In the original code, trump_tariff is a sticky value. If that’s intended/not intended, the above introduces/fixes a bug. ImHereToVote|10 months ago If statements are great because they are highly readable.
Upvoter33|10 months ago This 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 :) load replies (1)
Someone|10 months ago In the original code, trump_tariff is a sticky value. If that’s intended/not intended, the above introduces/fixes a bug.
unwind|10 months ago
Upvoter33|10 months ago
throwaway519|10 months ago
grokkedit|10 months ago
Someone|10 months ago
ImHereToVote|10 months ago