Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does an ellipsis do in PowerShell?

Tags:

powershell

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?

like image 762
Ian Pugsley Avatar asked Aug 30 '12 21:08

Ian Pugsley


People also ask

How do I expand three dots PowerShell?

On the PowerShell console, run $FormatEnumerationLimit =-1 and press Enter.

How do I expand PowerShell?

Use the –ExpandProperty parameter from Select-Object to expand objects in Windows PowerShell.

How do I get full results in 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.


1 Answers

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
like image 143
Ian Pugsley Avatar answered Oct 20 '22 11:10

Ian Pugsley