这段代码运行完美:
$table | update col { |row| "some value" } | print
这段代码也可以完美运行:
let $final_table = $table | update col { |row| "some value" }
$final_table | print
此代码在调用
Command does not support nothing
时抛出 update
错误:
$table = $table | update col { |row| "some value" }
$table | print
最后一个的唯一区别是设置了
$table
(可变变量),而不是新创建的变量或直接通过管道传输到 print
命令。为什么这会对代码错误产生影响?
这似乎是一个运算符优先级的问题。尝试一下
$table = ( $table | update col { |row| "some value" } )
$table | print