Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created May 11, 2020 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bielawb/dafd69de42e185958769f5cc2129783c to your computer and use it in GitHub Desktop.
Save bielawb/dafd69de42e185958769f5cc2129783c to your computer and use it in GitHub Desktop.
Świadome operowanie na zmiennej przez referencję
function Add-BarInfo {
param (
[hashtable]$Bary,
[string]$Nazwa,
[Int]$IlePiw
)
if ($Bary.Contains($Nazwa)) {
$Bary.$Nazwa += $IlePiw
} else {
$Bary.$Nazwa = $IlePiw
}
}
$mojeBary = @{}
Add-BarInfo -Bary $mojeBary -Nazwa Miś -IlePiw 2
Add-BarInfo -Bary $mojeBary -Nazwa Tani -IlePiw 5
Add-BarInfo -Bary $mojeBary -Nazwa Miś -IlePiw 2
$mojeBary.Miś
<#
Na wyjściu:
4
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment