-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Add any/all lambda containment operators #11068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
To reflect changes to binary comparison operators in PowerShell/PowerShell#11068
To reflect changes to binary comparison operators in PowerShell/PowerShell#11068
|
RE: The additional questions -- yes, I'd say it's worth including the negative versions, but I don't see a lot of value in a case-sensitive version, since folx can just use case-sensitive operators inside the scriptblock expression to get the same effect. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks lovely overall!
Couple minor thoughts in a few parts, but other than that this is good to go imo! 💖
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
8b0da2a to
e60f1d4
Compare
PR Summary
This pull request adds 2 new containment operators:
-any(ex.1..5 -any { $_ -eq 2 })lhsoperand and a predicate as itsrhsoperand. Returnstrueif the predicate istruefor any lhs value, returnsfalseotherwise-all(ex.1..5 -all { $_ -gt 0 })trueif the predicate istruefor all lhs value, returnsfalseotherwiseIf a non-delegate-like object is passed as the
rhsoperand, we perform a scalar equality comparison against each item inlhs.A related update to the EditorSyntax definition has been prepared here: PowerShell/EditorSyntax#189
PR Context
This PR is partly motivated by the discussion in #7925, and my own frustration with having to cast nested loop structures to perform similar containment testing.
For example, to find a directory in which all files a marked
hidden:(I'm aware that dynamic parameter aliases exist specifically for attribute filtering in the FileSystem provider, but that's sort of missing the point,
-any/-allwould work in any context)TODO:
-notany/-noneand-notall)-containsfallback edge case)PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.