mirror of
https://github.com/nushell/nushell.git
synced 2025-07-08 10:27:47 +02:00
Add new operators has
and not-has
(#14841)
# Description This PR add 2 new operators, `has` and `not-has`. They are basically `in` and `not-in` with the order of operands swapped. Motivation for this was the awkward way of searching for rows that contain an item using `where` ```nushell [[name, children]; [foo, [a, b, c]], [bar [d, e, f]]] | where ("e" in $it.children) ``` vs ```nushell [[name, children]; [foo, [a, b, c]], [bar [d, e, f]]] | where children has "e" ``` # User-Facing Changes Added `has` and `not-has` operators, mirroring `in` and `not-in`. # Tests + Formatting - 🟢 toolkit fmt - 🟢 toolkit clippy - 🟢 toolkit test - 🟢 toolkit test stdlib # After Submitting
This commit is contained in:
@ -141,6 +141,12 @@ fn description(operator: &Operator) -> &'static str {
|
||||
Operator::Comparison(Comparison::NotIn) => {
|
||||
"Checks if a value is not in a list, is not part of a string, or is not a key in a record."
|
||||
}
|
||||
Operator::Comparison(Comparison::Has) => {
|
||||
"Checks if a list contains a value, a string contains another, or if a record has a key."
|
||||
}
|
||||
Operator::Comparison(Comparison::NotHas) => {
|
||||
"Checks if a list does not contain a value, a string does not contain another, or if a record does not have a key."
|
||||
}
|
||||
Operator::Comparison(Comparison::StartsWith) => "Checks if a string starts with another.",
|
||||
Operator::Comparison(Comparison::EndsWith) => "Checks if a string ends with another.",
|
||||
Operator::Math(Math::Plus) => "Adds two values.",
|
||||
|
Reference in New Issue
Block a user