Reputation
247
Next privilege 250 Rep.
View close votes
Badges
2 6
Impact
~1k people reached

  • 0 posts edited
  • 2 helpful flags
  • 53 votes cast
Feb
11
comment Is it better to call a function multiple times, or to assign a variable multiple times and call the function once?
I think it depends on the language, the intent of changing the variables as such, and how likely you think you are going to need to change the arg's to the function. Many times, you could easily build a small hash/map object that has each of the conditions you need, keyed to that condition and then just call the variable with the value of the map. It doesn't really slim down the content, but it organizes and reduces the chance that you would miss a function call if you later need to edit the call.