I discovered that for the
Here is an example: If you have only objects in the list, and for each object you want to call its method
for item in list item.callMe () end
list.forEach (function (item) item.callMe () end)
The code can be more readable and without overwhelmingly typing the same thing.
Other functions also work. I tested:
forEach- calls the given function for all items in the list
every- checks if all elements of the list meet the condition of the anonymous function
reduce- allows you to perform operations on all items in the list and print the result
find- finds the first element in the list that satisfies the condition of the anoonym function
At the moment, I have only tested the
SLICE method - which is not present in MicroScript 2.0.
And it works .
Program code >>> here >>> https://microstudio.dev/i/Loginus/foreach23/