Skip to content

Commit ea7c6e1

Browse files
authored
Document range limits (#10907)
1 parent d108bd4 commit ea7c6e1

File tree

5 files changed

+164
-123
lines changed

5 files changed

+164
-123
lines changed

reference/5.1/Microsoft.PowerShell.Core/About/about_Operators.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Describes the operators that are supported by PowerShell.
33
Locale: en-US
4-
ms.date: 01/19/2024
4+
ms.date: 02/26/2024
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-5.1&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about Operators
@@ -521,8 +521,13 @@ You can also create ranges in reverse order.
521521
```
522522

523523
The start and end values of the range can be any pair of expressions that
524-
evaluate to an integer. For example, you could use the members of an
525-
enumeration for your start and end values.
524+
evaluate to an integer or a character. The endpoints of the range must be
525+
convertible to signed 32-bit integers (`[int32]`). Larger values cause an
526+
error. Also, if the range is captured in an array, the count of resulting is
527+
limited to maximum size of an array in .NET, which is `[int]::MaxValue - 56`.
528+
529+
For example, you could use the members of an enumeration for your start and end
530+
values.
526531

527532
```powershell
528533
PS> enum Food {

reference/7.2/Microsoft.PowerShell.Core/About/about_Operators.md

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Describes the operators that are supported by PowerShell.
33
Locale: en-US
4-
ms.date: 01/19/2024
4+
ms.date: 02/26/2024
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.2&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about Operators
@@ -575,6 +575,8 @@ values of the range.
575575
> [!NOTE]
576576
> Support for character ranges was added in PowerShell 6.
577577
578+
#### Number ranges
579+
578580
```powershell
579581
1..10
580582
$max = 10
@@ -588,6 +590,42 @@ You can also create ranges in reverse order.
588590
5..-5 | ForEach-Object {Write-Output $_}
589591
```
590592

593+
The start and end values of the range can be any pair of expressions that
594+
evaluate to an integer or a character. The endpoints of the range must be
595+
convertible to signed 32-bit integers (`[int32]`). Larger values cause an
596+
error. Also, if the range is captured in an array, the count of resulting is
597+
limited to maximum size of an array in .NET, which is `[int]::MaxValue - 56`.
598+
599+
For example, you could use the members of an enumeration for your start and end
600+
values.
601+
602+
```powershell
603+
PS> enum Food {
604+
Apple
605+
Banana = 3
606+
Kiwi = 10
607+
}
608+
PS> [Food]::Apple..[Food]::Kiwi
609+
0
610+
1
611+
2
612+
3
613+
4
614+
5
615+
6
616+
7
617+
8
618+
9
619+
10
620+
```
621+
622+
> [!IMPORTANT]
623+
> The resulting range isn't limited to the values of the enumeration. Instead
624+
> it represents the range of values between the two values provided. You can't
625+
> use the range operator to reliably represent the members of an enumeration.
626+
627+
#### Character ranges
628+
591629
To create a range of characters, enclose the characters in quotes.
592630

593631
```powershell
@@ -646,35 +684,6 @@ Y
646684
X
647685
```
648686

649-
The start and end values of the range can be any pair of expressions that
650-
evaluate to an integer or a character. For example, you could use the members
651-
of an enumeration for your start and end values.
652-
653-
```powershell
654-
PS> enum Food {
655-
Apple
656-
Banana = 3
657-
Kiwi = 10
658-
}
659-
PS> [Food]::Apple..[Food]::Kiwi
660-
0
661-
1
662-
2
663-
3
664-
4
665-
5
666-
6
667-
7
668-
8
669-
9
670-
10
671-
```
672-
673-
> [!IMPORTANT]
674-
> The resulting range isn't limited to the values of the enumeration. Instead
675-
> it represents the range of values between the two values provided. You can't
676-
> use the range operator to reliably represent the members of an enumeration.
677-
678687
### Member-access operator `.`
679688

680689
Accesses the properties and methods of an object. The member name may be an

reference/7.3/Microsoft.PowerShell.Core/About/about_Operators.md

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Describes the operators that are supported by PowerShell.
33
Locale: en-US
4-
ms.date: 01/19/2024
4+
ms.date: 02/26/2024
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.3&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about Operators
@@ -575,6 +575,8 @@ values of the range.
575575
> [!NOTE]
576576
> Support for character ranges was added in PowerShell 6.
577577
578+
#### Number ranges
579+
578580
```powershell
579581
1..10
580582
$max = 10
@@ -588,6 +590,42 @@ You can also create ranges in reverse order.
588590
5..-5 | ForEach-Object {Write-Output $_}
589591
```
590592

593+
The start and end values of the range can be any pair of expressions that
594+
evaluate to an integer or a character. The endpoints of the range must be
595+
convertible to signed 32-bit integers (`[int32]`). Larger values cause an
596+
error. Also, if the range is captured in an array, the count of resulting is
597+
limited to maximum size of an array in .NET, which is `[int]::MaxValue - 56`.
598+
599+
For example, you could use the members of an enumeration for your start and end
600+
values.
601+
602+
```powershell
603+
PS> enum Food {
604+
Apple
605+
Banana = 3
606+
Kiwi = 10
607+
}
608+
PS> [Food]::Apple..[Food]::Kiwi
609+
0
610+
1
611+
2
612+
3
613+
4
614+
5
615+
6
616+
7
617+
8
618+
9
619+
10
620+
```
621+
622+
> [!IMPORTANT]
623+
> The resulting range isn't limited to the values of the enumeration. Instead
624+
> it represents the range of values between the two values provided. You can't
625+
> use the range operator to reliably represent the members of an enumeration.
626+
627+
#### Character ranges
628+
591629
To create a range of characters, enclose the characters in quotes.
592630

593631
```powershell
@@ -646,35 +684,6 @@ Y
646684
X
647685
```
648686

649-
The start and end values of the range can be any pair of expressions that
650-
evaluate to an integer or a character. For example, you could use the members
651-
of an enumeration for your start and end values.
652-
653-
```powershell
654-
PS> enum Food {
655-
Apple
656-
Banana = 3
657-
Kiwi = 10
658-
}
659-
PS> [Food]::Apple..[Food]::Kiwi
660-
0
661-
1
662-
2
663-
3
664-
4
665-
5
666-
6
667-
7
668-
8
669-
9
670-
10
671-
```
672-
673-
> [!IMPORTANT]
674-
> The resulting range isn't limited to the values of the enumeration. Instead
675-
> it represents the range of values between the two values provided. You can't
676-
> use the range operator to reliably represent the members of an enumeration.
677-
678687
### Member-access operator `.`
679688

680689
Accesses the properties and methods of an object. The member name may be an

reference/7.4/Microsoft.PowerShell.Core/About/about_Operators.md

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Describes the operators that are supported by PowerShell.
33
Locale: en-US
4-
ms.date: 01/19/2024
4+
ms.date: 02/26/2024
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.4&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about Operators
@@ -575,6 +575,8 @@ values of the range.
575575
> [!NOTE]
576576
> Support for character ranges was added in PowerShell 6.
577577
578+
#### Number ranges
579+
578580
```powershell
579581
1..10
580582
$max = 10
@@ -588,6 +590,42 @@ You can also create ranges in reverse order.
588590
5..-5 | ForEach-Object {Write-Output $_}
589591
```
590592

593+
The start and end values of the range can be any pair of expressions that
594+
evaluate to an integer or a character. The endpoints of the range must be
595+
convertible to signed 32-bit integers (`[int32]`). Larger values cause an
596+
error. Also, if the range is captured in an array, the count of resulting is
597+
limited to maximum size of an array in .NET, which is `[int]::MaxValue - 56`.
598+
599+
For example, you could use the members of an enumeration for your start and end
600+
values.
601+
602+
```powershell
603+
PS> enum Food {
604+
Apple
605+
Banana = 3
606+
Kiwi = 10
607+
}
608+
PS> [Food]::Apple..[Food]::Kiwi
609+
0
610+
1
611+
2
612+
3
613+
4
614+
5
615+
6
616+
7
617+
8
618+
9
619+
10
620+
```
621+
622+
> [!IMPORTANT]
623+
> The resulting range isn't limited to the values of the enumeration. Instead
624+
> it represents the range of values between the two values provided. You can't
625+
> use the range operator to reliably represent the members of an enumeration.
626+
627+
#### Character ranges
628+
591629
To create a range of characters, enclose the characters in quotes.
592630

593631
```powershell
@@ -646,35 +684,6 @@ Y
646684
X
647685
```
648686

649-
The start and end values of the range can be any pair of expressions that
650-
evaluate to an integer or a character. For example, you could use the members
651-
of an enumeration for your start and end values.
652-
653-
```powershell
654-
PS> enum Food {
655-
Apple
656-
Banana = 3
657-
Kiwi = 10
658-
}
659-
PS> [Food]::Apple..[Food]::Kiwi
660-
0
661-
1
662-
2
663-
3
664-
4
665-
5
666-
6
667-
7
668-
8
669-
9
670-
10
671-
```
672-
673-
> [!IMPORTANT]
674-
> The resulting range isn't limited to the values of the enumeration. Instead
675-
> it represents the range of values between the two values provided. You can't
676-
> use the range operator to reliably represent the members of an enumeration.
677-
678687
### Member-access operator `.`
679688

680689
Accesses the properties and methods of an object. The member name may be an

0 commit comments

Comments
 (0)