如下代碼
let names= ["Anna", "Tom", "Alex", "Paul"]
for name in names{
println("Hello, (name)!")
}
playground報錯,總說unexpected character。
感謝2l的回答,之前重新輸入的時候疏忽了
在字符串中接入變量格式是: (變量)
正確寫法:
let names= ["Anna", "Tom", "Alex", "Paul"]
for name in names{
println("Hello, (name) !")
}