diff --git a/crates/nu-command/src/filters/filter.rs b/crates/nu-command/src/filters/filter.rs index e092c1f119..fc3b713ffd 100644 --- a/crates/nu-command/src/filters/filter.rs +++ b/crates/nu-command/src/filters/filter.rs @@ -32,6 +32,7 @@ a variable. On the other hand, the "row condition" syntax is not supported."# Type::List(Box::new(Type::Any)), ), (Type::Table(vec![]), Type::Table(vec![])), + (Type::Range, Type::List(Box::new(Type::Any))), ]) .required( "closure", @@ -224,6 +225,14 @@ a variable. On the other hand, the "row condition" syntax is not supported."# span: Span::test_data(), }), }, + Example { + description: "Filter items of a range according to a condition", + example: "9..13 | filter {|el| $el mod 2 != 0}", + result: Some(Value::List { + vals: vec![Value::test_int(9), Value::test_int(11), Value::test_int(13)], + span: Span::test_data(), + }), + }, // TODO: This should work but does not. (Note that `Let` must be present in the working_set in `example_test.rs`). // See https://github.com/nushell/nushell/issues/7034 // Example {