Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
New line after pipeline? #106
Comments
|
I personally do it like this: Get-Process |
Sort-Object -Property Name |
Out-GridViewWhen I'm writing scripts anyway. I don't do that when I'm using the shell. |
|
Reability is more important and having it all on one line makes it more difficult to understand at a quick glance. If your code is more readable over multiple lines then break it up. |
|
If we care about readability, we sure might want to chime in on a very relevant PowerShell issue: When it comes to style, clarity, and readability, the options below are organized from best to worst: # Doesn't work, but it _should_
Get-PSSession
| Where-Object { $_.computername -like "*.outlook.com" }
| Remove-PSSessionGet-PSSession |
Where-Object { $_.computername -like "*.outlook.com" } |
Remove-PSSessionGet-PSSession `
| Where-Object { $_.computername -like "*.outlook.com" } `
| Remove-PSSessionGet-PSSession |
Where-Object { $_.computername -like "*.outlook.com" } |
Remove-PSSessionGet-PSSession | Where-Object { $_.computername -like "*.outlook.com" } | Remove-PSSessionGet-PSSession |
Where-Object { $_.computername -like "*.outlook.com" } |
Remove-PSSessionThe version with backticks is better than the pyramid indent but worse than the single indent because it is slightly harder to maintain, but it remains easier to read and understand especially with long or complex pipelines. |
|
That first option is very F#-like. I approve. let f1 str server =
str
|> parseUserName
|> getUserByName server
|> validateLogin <| DateTime.NowGetting that to work, though, would be a fairly big task, I think. It goes against a few established behaviours. Currently my go to is option 2. |
What do you think about the pipeline and newlines.