I’m familiar with the basic range operator:
.. Range operator
Represents the sequential integers in an integer array, given an upper and lower boundary.
1..10
10..1
foreach ($a in 1..$max) {write-host $a}
However, I accidently used an ellipsis (...) instead of a range operator (..) today, and noticed it enumerated from N down to 0 for some reason:
PS C:\> 5...3
5
4
3
2
1
0
What’s going on?
The range operator is still being used – as it turns out, the second input (in this case,
.3) to the range operator is being implicitly cast to an integer, since the range operator only accepts integers as inputs.This can be verified by using a right-side value higher than
.5:This is much easier to see when you use an obviously non-integer value as the right-side value for the range operator: