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?
On the PowerShell console, run $FormatEnumerationLimit =-1 and press Enter.
Use the –ExpandProperty parameter from Select-Object to expand objects in Windows PowerShell.
All you have to do is to go to Out-String and add the -Width parameter. Keep in mind that the -Width parameter of Out-File cmdlet specifies the number of characters in each line of output. Any other characters will simply be truncated, not wrapped.
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:
PS C:\> 5...6
5
4
3
2
1
This is much easier to see when you use an obviously non-integer value as the right-side value for the range operator:
PS C:\> 5..'3'
5
4
3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With