If I define a class of fuzzy, with its various variables and methods, I can easily create an array of
Dealing with the individual elements, such as cats is straightforward.
Is there a way to deal with all of the members at once?
For example, suppose I want
to apply public routine pet() to each element?
I'm thinking of a situation where I create an array as above by declaring some element for the constricted (such as which pin to use), but want a generalized situation to maintain the elements (perhaps they need to check status, or turn off at a time stored in private variable, or . . .).
Being able to call the method for an entire array would seem to be cleaner code than an explicit loop (as well as the issue of coding the size of the array to get the exit condition of the loop).
[and, yes, all these years later I'm still grumbling that HyperTalk didn't allow "send thisMessage to every field on this card", as I had to work around it then, and still do in the modern successor LiveCode . . .]
The particular instance that brought it up is a class for relays, for which I want to check all of the off times, or for which I would want a call to any element of the array to turn on that element to first turn off all (whether for current usage, or because they would open too many water valves to maintain pressure, or let multiple model trains out of the station, or . . .)