This code runs perfectly:
$table | update col { |row| "some value" } | print
This code also runs perfectly:
let $final_table = $table | update col { |row| "some value" }
$final_table | print
This code throws a Command does not support nothing error on the call to update:
$table = $table | update col { |row| "some value" }
$table | print
The only difference in the last one is that $table (a mutable variable) is being set, instead of a newly created variable or just directly pipelining to the print command. Why would that make a difference to this code, erroring or not?
Since Nushell 0.83, declaration keywords such as
letandmutno longer require the use of subexpressions to assign the output of a pipeline to a variable (see blog).However, assigning the output of a pipeline to a mutable variable as you are doing in this case is an intentional exception to this language improvement. For that, you'll still need to use subexpressions:
Note that I also simplified your
updatecommand here, as it only contained a static value.Given the language improvement, this could also be done using the
letormutkeywords. For example:or
However, redeclaring (shadowing) the same variable is not a good practice. Best to continue to use subexpressions for this purpose, as demonstrated in the first example above.