Skip to content

Instantly share code, notes, and snippets.

@Lucy-vP
Created December 9, 2021 09:57
Show Gist options
  • Save Lucy-vP/f7416b8712ba5ccc8c132da70ac3ff83 to your computer and use it in GitHub Desktop.
Save Lucy-vP/f7416b8712ba5ccc8c132da70ac3ff83 to your computer and use it in GitHub Desktop.
###########################################################################################################
## Don't do this @home!
## https://www.youtube.com/watch?v=1f1Y0ICtpTA&t=3s
## docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables#_
## https://github.com/Lucy-vP/pssb/blob/readingsample/002.ps1
###########################################################################################################
$characters =
'Charlie Brown',
'Snoopy',
'Schroeder',
'Lucy van Pelt',
'Linus van Pelt',
'Sally Brown',
'Peppermint Patty',
'Woodstock','Marcie',
'Rerun van Pelt',
'Spike'
## TRY: Pipelining
$characters | foreach { $_ }
$characters | foreach { $_ } | select -f 3
## CRY: Looping
foreach ($_ in $characters) { $_ }
foreach ($_ in $characters) { $_ } | select -f 3
## FINALLY: in terms of readability and clarity, you should always do it like this:
$characters | ForEach-Object -Process { $_ }
foreach ($character in $characters) { $character }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment