mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:24:58 +02:00
Paren interpolation (#3452)
* Switch interp to use parens * improve interp parsing
This commit is contained in:
@ -52,7 +52,7 @@ impl WholeStreamCommand for Each {
|
||||
Example {
|
||||
description: "Number each item and echo a message",
|
||||
example:
|
||||
"echo ['bob' 'fred'] | each --numbered { echo $\"{$it.index} is {$it.item}\" }",
|
||||
"echo ['bob' 'fred'] | each --numbered { echo $\"($it.index) is ($it.item)\" }",
|
||||
result: Some(vec![Value::from("0 is bob"), Value::from("1 is fred")]),
|
||||
},
|
||||
Example {
|
||||
|
@ -8,20 +8,23 @@ fn reduce_table_column() {
|
||||
echo "[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]"
|
||||
| from json
|
||||
| get total
|
||||
| reduce -f 20 { $it + (math eval $"{$acc}^1.05")}
|
||||
| reduce -f 20 { $it + (math eval $"($acc)^1.05")}
|
||||
| str from -d 1
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "180.6");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reduce_table_column_with_path() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo "[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]"
|
||||
| from json
|
||||
| reduce -f 20 { $it.total + (math eval $"{$acc}^1.05")}
|
||||
| reduce -f 20 { $it.total + (math eval $"($acc)^1.05")}
|
||||
| str from -d 1
|
||||
"#
|
||||
)
|
||||
|
Reference in New Issue
Block a user