mirror of
https://github.com/nushell/nushell.git
synced 2024-12-26 08:59:12 +01:00
fa5d7babb9
# Description This PR addresses #11204 which points out that using a closure for the replacement value with `update`, `insert`, or `upsert` does not work for lists. # User-Facing Changes - Replacement closures should now work for lists in `upsert`, `insert`, and `update`. E.g., `[0] | update 0 {|i| $i + 1 }` now gives `[1]` instead of an unhelpful error. - `[1 2] | insert 4 20` no longer works. Before, this would give `[1, 2, null, null, 20]`, but now it gives an error. This was done to match the intended behavior in `Value::insert_data_at_cell_path`, whereas the behavior before was probably unintentional. Following `Value::insert_data_at_cell_path`, inserting at the end of a list is also fine, so the valid indices for `upsert` and `insert` are `0..=length` just like `Vec::insert` or list inserts in other languages. # Tests + Formatting Added tests for `upsert`, `insert`, and `update`: - Replacement closures for lists, list streams, records, and tables - Other list stream tests |
||
---|---|---|
.. | ||
commands | ||
format_conversions | ||
main.rs |