Consider the following
arr = [5, 4, 3, 2, 1]
arr.each_with_index { |val, index| dosomething...}
Based on my testimony, Ruby will iterate over the array in sequential order (5, 4, 3 ...). My question is, is this behavior guaranteed by the language or its specification? In particular, future versions of Ruby prevent iteration of the array from repeating in parallel or in a different sequential order? In different ways, this is sequential processing of array elements with each call to the CONVENTION or SPECIFICATION function.
Let's look at these two topics separately.
Inconsistent order: Can future versions of Ruby, without violating the language specification, make it possible to decide that the best way to execute each_with_index is [2, 3, 5, 4, 1]?
Parallel Processing: Consider a future (or perhaps an existing, but unknown to me) version of Ruby for large-scale parallel processing. Without breaking the language specification, can this version of Ruby potentially handle 3, 2, and 1 at the same time, and then after that 4 and 5?
Rate the feedback.
source
share