Optimize function with complex square root

eachindex is more generic, enumerate does not give indexes, it gives 1 with the first element, 2 with the second, and so on; if your Array has more than one dimension, or custom indexes (start at 0 for example) then your code will break. eachindex will always give valid indexes, and for N-dimensional arrays, it will give the indexes in the most efficient order for linear access. If you want something that both give you valid indexes and the value then look at pairs documentation and use it instead of enumerate.

I talk a little more about this in my answer of mine.

3 Likes