Beginning and the end? I would use:
foo = 1..2 foo.min
Trying to use restructuring for a range is a bad idea. Imagine the dimensions of an array that can be generated, then thrown away, wasting time and processor memory. This is a really great way to DOS your own code if your range ends in Float::INFINITY .
end does not match max : at 1 ... 10, end is 10, but max is 9
This is because start_val ... end_val equivalent to start_val .. (end_val - 1) :
start_value = 1 end_value = 2 foo = start_value...end_value foo.end
max reflects the reality of the values actually used by Ruby when iterating over a range or testing for inclusion in a range.
In my opinion, end should reflect the actual maximum value that will be considered within the range, not the value used at the end of the range definition, but I doubt it will change, otherwise the existing code will affect it.
... more confusing and leads to increased maintenance problems, so its use is not recommended.
source share