Skip to main content
Commonmark migration
Source Link

##PowerShell##

PowerShell

This creates an object whose state property is the names of the variables that point to the object.

$a = @{}| Add-Member -MemberType:16 -PassThru state -Value {
        (gv|?{$this -eq $_.Value}|%{$_.Name}) -join ','} 

'Before: ' + $a.state
$b = $a
'After: ' + $a.state

Output

Before: a,this
After: a,b,this

Note: This doesn't work if the assignment happens in a child scope.

'Before: ' + $a.state
&{$b = $a}
'After: ' + $a.state

Outputs

Before: a,this
After: a,this

##PowerShell##

This creates an object whose state property is the names of the variables that point to the object.

$a = @{}| Add-Member -MemberType:16 -PassThru state -Value {
        (gv|?{$this -eq $_.Value}|%{$_.Name}) -join ','} 

'Before: ' + $a.state
$b = $a
'After: ' + $a.state

Output

Before: a,this
After: a,b,this

Note: This doesn't work if the assignment happens in a child scope.

'Before: ' + $a.state
&{$b = $a}
'After: ' + $a.state

Outputs

Before: a,this
After: a,this

PowerShell

This creates an object whose state property is the names of the variables that point to the object.

$a = @{}| Add-Member -MemberType:16 -PassThru state -Value {
        (gv|?{$this -eq $_.Value}|%{$_.Name}) -join ','} 

'Before: ' + $a.state
$b = $a
'After: ' + $a.state

Output

Before: a,this
After: a,b,this

Note: This doesn't work if the assignment happens in a child scope.

'Before: ' + $a.state
&{$b = $a}
'After: ' + $a.state

Outputs

Before: a,this
After: a,this
added 198 characters in body
Source Link
Rynant
  • 2.4k
  • 15
  • 19

##PowerShell##

This creates an object whose state property is the names of the variables that point to the object.

$a = @{}| Add-Member -MemberType:16 -PassThru state -Value {
        (gv|?{$this -eq $_.Value}|%{$_.Name}) -join ','} 

'Before: ' + $a.state
$b = $a
'After: ' + $a.state

Output

Before: a,this
After: a,b,this

Note: This doesn't work if the assignment happens in a child scope.

'Before: ' + $a.state
&{$b = $a}
'After: ' + $a.state

Outputs

Before: a,this
After: a,this

##PowerShell##

This creates an object whose state property is the names of the variables that point to the object.

$a = @{}| Add-Member -MemberType:16 -PassThru state -Value {
        (gv|?{$this -eq $_.Value}|%{$_.Name}) -join ','} 

'Before: ' + $a.state
$b = $a
'After: ' + $a.state

Output

Before: a,this
After: a,b,this

##PowerShell##

This creates an object whose state property is the names of the variables that point to the object.

$a = @{}| Add-Member -MemberType:16 -PassThru state -Value {
        (gv|?{$this -eq $_.Value}|%{$_.Name}) -join ','} 

'Before: ' + $a.state
$b = $a
'After: ' + $a.state

Output

Before: a,this
After: a,b,this

Note: This doesn't work if the assignment happens in a child scope.

'Before: ' + $a.state
&{$b = $a}
'After: ' + $a.state

Outputs

Before: a,this
After: a,this
Source Link
Rynant
  • 2.4k
  • 15
  • 19

##PowerShell##

This creates an object whose state property is the names of the variables that point to the object.

$a = @{}| Add-Member -MemberType:16 -PassThru state -Value {
        (gv|?{$this -eq $_.Value}|%{$_.Name}) -join ','} 

'Before: ' + $a.state
$b = $a
'After: ' + $a.state

Output

Before: a,this
After: a,b,this