diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Ref.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Ref.md index 289ead3f34fe..d3144b572ddb 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Ref.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Ref.md @@ -17,9 +17,9 @@ Describes how to create and use a reference type variable. You can pass variables to functions _by reference_ or _by value_. When you pass a variable _by value_, you are passing a copy of the data. When you pass a variable _by reference_, you are passing a reference to the original value. -This allows the function to change the value of the variable that is passed to -it.Reference types are created using `[ref]`, which is the type accelerator for -the `[System.Management.Automation.PSReference]` type. +This allows the function to change the value of the variable that's passed to +it. Reference types are created using `[ref]`, which is the type accelerator +for the `[System.Management.Automation.PSReference]` type. The primary purpose of `[ref]` is to enable passing PowerShell variables by reference to .NET method parameters marked as `ref`, `out`, or `in`. You can @@ -83,14 +83,14 @@ When using references, you must use the `Value` property of the `[ref]` type to access your data. ```powershell -Function Test([ref]$data) -{ +function Test { + param([ref]$data) $data.Value = 3 } ``` -To pass a variable to a parameter that expects a reference, you must type -cast your variable as a reference. +To pass a variable to a parameter that expects a reference, you must type cast +your variable as a reference. > [!IMPORTANT] > The brackets and parenthesis are BOTH required. @@ -183,9 +183,9 @@ Get-ChildItem -File $setPath | ## Difference between `[ref]` and `[System.Management.Automation.PSReference]` -A reference type variable is created using - -Even though `[ref]` is a type accelerator for +A reference type variable is created using the `[ref]` type accelerator or by +specifying the `[System.Management.Automation.PSReference]` type directly. Even +though `[ref]` is a type accelerator for `[System.Management.Automation.PSReference]`, they behave differently. - When you use `[ref]` to cast a variable, PowerShell creates a reference object diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Ref.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Ref.md index f0c4227c144a..29cfa3048727 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Ref.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Ref.md @@ -17,9 +17,9 @@ Describes how to create and use a reference type variable. You can pass variables to functions _by reference_ or _by value_. When you pass a variable _by value_, you are passing a copy of the data. When you pass a variable _by reference_, you are passing a reference to the original value. -This allows the function to change the value of the variable that is passed to -it.Reference types are created using `[ref]`, which is the type accelerator for -the `[System.Management.Automation.PSReference]` type. +This allows the function to change the value of the variable that's passed to +it. Reference types are created using `[ref]`, which is the type accelerator +for the `[System.Management.Automation.PSReference]` type. The primary purpose of `[ref]` is to enable passing PowerShell variables by reference to .NET method parameters marked as `ref`, `out`, or `in`. You can @@ -83,14 +83,14 @@ When using references, you must use the `Value` property of the `[ref]` type to access your data. ```powershell -Function Test([ref]$data) -{ +function Test { + param([ref]$data) $data.Value = 3 } ``` -To pass a variable to a parameter that expects a reference, you must type -cast your variable as a reference. +To pass a variable to a parameter that expects a reference, you must type cast +your variable as a reference. > [!IMPORTANT] > The brackets and parenthesis are BOTH required. @@ -183,9 +183,9 @@ Get-ChildItem -File $setPath | ## Difference between `[ref]` and `[System.Management.Automation.PSReference]` -A reference type variable is created using - -Even though `[ref]` is a type accelerator for +A reference type variable is created using the `[ref]` type accelerator or by +specifying the `[System.Management.Automation.PSReference]` type directly. Even +though `[ref]` is a type accelerator for `[System.Management.Automation.PSReference]`, they behave differently. - When you use `[ref]` to cast a variable, PowerShell creates a reference object diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Ref.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Ref.md index 8bf41acd8b0b..77fc4184c545 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Ref.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Ref.md @@ -17,9 +17,9 @@ Describes how to create and use a reference type variable. You can pass variables to functions _by reference_ or _by value_. When you pass a variable _by value_, you are passing a copy of the data. When you pass a variable _by reference_, you are passing a reference to the original value. -This allows the function to change the value of the variable that is passed to -it.Reference types are created using `[ref]`, which is the type accelerator for -the `[System.Management.Automation.PSReference]` type. +This allows the function to change the value of the variable that's passed to +it. Reference types are created using `[ref]`, which is the type accelerator +for the `[System.Management.Automation.PSReference]` type. The primary purpose of `[ref]` is to enable passing PowerShell variables by reference to .NET method parameters marked as `ref`, `out`, or `in`. You can @@ -83,14 +83,14 @@ When using references, you must use the `Value` property of the `[ref]` type to access your data. ```powershell -Function Test([ref]$data) -{ +function Test { + param([ref]$data) $data.Value = 3 } ``` -To pass a variable to a parameter that expects a reference, you must type -cast your variable as a reference. +To pass a variable to a parameter that expects a reference, you must type cast +your variable as a reference. > [!IMPORTANT] > The brackets and parenthesis are BOTH required. @@ -183,9 +183,9 @@ Get-ChildItem -File $setPath | ## Difference between `[ref]` and `[System.Management.Automation.PSReference]` -A reference type variable is created using - -Even though `[ref]` is a type accelerator for +A reference type variable is created using the `[ref]` type accelerator or by +specifying the `[System.Management.Automation.PSReference]` type directly. Even +though `[ref]` is a type accelerator for `[System.Management.Automation.PSReference]`, they behave differently. - When you use `[ref]` to cast a variable, PowerShell creates a reference object