Skip to content

Conversation

@najoast
Copy link
Contributor

@najoast najoast commented May 22, 2024

Why submit this PR?

#16 (comment)

参数名使用 options 的原因

这个参数表示一组选项,而不是单独的一个选项。使用复数形式更加准确地描述了它的性质。
同时也可以提高代码的可读性,比如:

for _, option in pairs(options) do
end

local option = options[xxx]

没有使用 opts,因为 options 本身不是很长,没必要缩写。虽然很多库都使用 opts 作为选项参数名,但严格来说这是一种有损压缩,只有知道这个惯例的人才看的懂。

参数标注

对于 options 参数的说明,使用了 Emmylua 的标注
好处是直观/易懂,且对于使用了 Emmylua 插件的同学来说,还可以智能提示。

@xjdrew
Copy link
Owner

xjdrew commented Sep 12, 2025

@najoast 不好意思,没有及时处理,导致代码冲突了;能否rebase一下再推上来;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants