News for hackers. Stuff that matters.
Re:Push ifs up and fors down by dg44768 on Thursday November 16, 2023 @12:05AM (#38285953)
Thanks for the article. Maybe I’m confused, but why in the section near the end about how the two recommendations go together, why is the code this:

if condition { for walrus in walruses { walrus.frobnicate() } } else { for walrus in walruses { walrus.transmogrify() } } and not this?

if condition { frobnicate_batch(walruses) } else { transmogrify_batch(walruses) }

Re:Push ifs up and fors down by BenFrantzDale on Thursday November 16, 2023 @07:30AM (#38288759)
I thought that too. I think the point there was that you don’t have to push this notion as afar as in/out of functions: that just flipping them within a function can be beneficial.