Skip to content
New issue

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

编译出错 #10

Open
flymyd opened this issue Jul 7, 2020 · 3 comments
Open

编译出错 #10

flymyd opened this issue Jul 7, 2020 · 3 comments

Comments

@flymyd
Copy link

flymyd commented Jul 7, 2020

Swift编译器在此处报错:
/PrincessGuide-master/PrincessGuide/Model/Action/ChangeEnergyRatioAction.swift:18:26: Type of expression is ambiguous without more context

报错行具体代码为:
children.map(.parameter.id).map { String($0 % 10) }.joined(separator: ", "),

@superk589
Copy link
Owner

superk589 commented Jul 7, 2020

这个地方原本的代码是 children.map(\.parameter.id)
你应该是不小心把这个"\"删了

@flymyd
Copy link
Author

flymyd commented Jul 7, 2020

我复制的时候出的问题。加了\也不行;appcode和xcode都无法编译通过。
尝试改为如下可以解决,但我本身没有使用过swift,不清楚会不会影响正常功能。
children.map{ _ in
parent!.parameter.id}.map { String($0 % 10) }.joined(separator: ", "),

@superk589
Copy link
Owner

建议使用最新的Xcode 11.5 这个语法老版本可能不支持
如果确实是不支持 可以将 children.map(\.parameter.id) 改为 children.map { $0.parameter.id }

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

No branches or pull requests

2 participants