初始化没有可选属性的结构

问题描述 投票:-1回答:1

我希望能够创建此结构的对象而不必初始化2个可选的双精度值enter image description here

swift xcode struct initialization optional
1个回答
0
投票

您可以使用默认值作为属性。

init(presentValue: Double, rate: Double, time: Double, frequency: Double = 0.0) {
...
}
© www.soinside.com 2019 - 2024. All rights reserved.