We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
有些参数存在服务器字段缺失或没有值的问题,我也不需要设置默认值(或者说,没有办法为某些属性设置一个合理的默认值)。 声明 Optional 类型的属性:
@Codec("pic") var imageURL: URL?
会报编译器红色错误:❌ type of expression is ambiguous without more context。
❌ type of expression is ambiguous without more context
要将属性设置成有默认值的非可选类型,或者:
@Codec("pic") var imageURL: URL? = nil
才可以编译通过。
【问题】Optional 类型的语义就是:要么它存在值,不存在值默认就是 nil,在声明时还需要主动赋值 nil 有点多余。
nil
The text was updated successfully, but these errors were encountered:
是有这个问题且我们已经注意到了,但是不太好修复跟另外一个feature冲突。所以目前Optional省略= nil只支持没有key参数的Codec。
= nil
// 这么写是可以的 @Codec var imageURL: URL? // 这么写目前不行 @Codec("pic") var imageURL: URL?
如果未来找到办法的话我们会解决这个用户体验不好的问题,毕竟做这个库的目的是为了提升用户体验。
Sorry, something went wrong.
resolved in 1.0
No branches or pull requests
有些参数存在服务器字段缺失或没有值的问题,我也不需要设置默认值(或者说,没有办法为某些属性设置一个合理的默认值)。
声明 Optional 类型的属性:
会报编译器红色错误:
❌ type of expression is ambiguous without more context
。要将属性设置成有默认值的非可选类型,或者:
才可以编译通过。
【问题】Optional 类型的语义就是:要么它存在值,不存在值默认就是
nil
,在声明时还需要主动赋值nil
有点多余。The text was updated successfully, but these errors were encountered: