我正在学习使用Ubuntu 16.01在swift中编码,并且我遵循The Swift Programming Language (Swift3)教程。
当我尝试编写第11页中显示的代码时:
let interestingNumbers = [
"Prime":[2,3,5,7,11,13],
"Fibonacci":[1,1,2,3,5,8],
"Square":[1,4,9,16,25],
]
var largest = 0
for(kind, numbers) in interestingNumbers {
for number in numbers {
if number > largest {
largest = number
}
}
}
print(largest)
当我执行时,表示相应行中发生错误:
error: repl.swift:12:22: error: ambiguous use of 'interestingNumbers'
for (kind, numbers) in (interestingNumbers) {
^
repl.swift:6:5: note: found this candidate
let interestingNumbers = [
^
我试图用以下方法解决它:
for (kind, numbers) in #selector(interestingNumbers) {
但它说:
错误:repl.swift:12:21:错误:' #selector'只能与Objective-C运行时一起使用
我该如何解决这个问题?