0
Is it normal to save functions in array?
3 Antworten
+ 2
I guess you should specify the language or otherwise it would be too broad to answer.
Generally it's uncommon as the purpose of an array is to allow an index-based iteration of same type of data while function encourage code reuse without duplicating similar logic.
I'm not aware of the benefit of combining the two and perhaps it's only useful in a very specific scenario.
+ 1
Array is a list of things.
Function is a group of commands that can be executed when you call it (use its function name).
So, surely you can store functions' names (or pointers) in an array. It is normal.
In the subscription model where several client objects register with a server object in order to receive notifications from the server object when some event happens, server object keeps a list (or array) of callback functions of the clients, and execute all of those functions.
0
Something in the water this week?
https://www.sololearn.com/discuss/1499970/?ref=app