2 ms·
You have a bunch of functions in a list. You choose one of these functions via some criteria, and run it with some provided parameters. Why it is so different
by javcasas 5y ago
You have a bunch of functions in a list. You choose one of these functions via some criteria, and run it with some provided parameters.
Why it is so different to having a bunch of numbers in a list and choosing one of these numbers via some criteria, then doing one of the allowed operations for that number?
Bear in mind with the function I'm doing exactly the same: do one of the allowed operations for it (invoke the function).
- valenterry 5y agoDifferent functions can expect different arguments. For numbers, they are all the same. That's a difference! Well, you can argue that there are also different numbers and you can do devision only by some of them. But in fact, if you were to separate them and wrap them to do things differently, then this would get closer to the strategy pattern.