【发布时间】:2023-04-03 17:05:02
【问题描述】:
以下代码产生Error: argument is missing, with no default,因为来自调用者的尾随逗号。
new_game <- function(...) {
list(...)
}
game <- new_game(
c(1,2,3),
c(1,2),
c(3),
c(2),
c(1), # the comma here is the culprit
)
是否可以通过简单地忽略最后一个“参数”来规避这个错误?
我想这样设计我的函数,因为类似于 Rust 在匹配语句或结构中的 trailing commas,或者 Go 在复合文字中的 trailing commas,它使重新排列、添加、删除行和提交和拉取更改。
【问题讨论】: