Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
苹果文档说,
“输入输出参数不能有默认值,可变参数不能标记为输入输出”。
为什么我们被限制这样做?
到目前为止我的理解:
我们不能将常量/文字传递给输入参数。因为常量/文字是不可变的,无法更改。
但是对于可变参数,我们可以将常量/文字作为参数传递。因此,如果我们可以将 Variadics 设为 inout,则与上述事实相矛盾。
关于可变参数的默认值,可变参数的默认值是一个空数组。附上游乐场图片。
如果我有不正确的理解,请告诉我。