import UIKit
var str = "Hello, playground"
let NumberofStopLights: Int = 4
var population: Int
population = 5000
let TownName = "HappyPlace"
let TownDescription = return "/(TownName) has a population of /(population) and /(numberofStopLights) Stop Lights
print (TownDescription)
我希望整数自动进入/(TownName),/(population)和/(numberStopLights)空格,尝试使用return函数,但它不起作用。所以......我试着根据Stack Overflow上的另一篇文章做了这个,它说要把它放在它面前,但那不起作用,所以...下一步是什么? (上面的代码)
答案 0 :(得分:2)
你不需要返回,你的插值也是错误的。应该是\()而不是/()而你忘记了最后一个“在声明你的Townname字符串时。
var str = "Hello, playground"
let NumberofStopLights: Int = 4
var population: Int
population = 5000
let TownName = "HappyPlace"
let TownDescription = "\(TownName) has a population of \(population) and \(NumberofStopLights) Stop Lights"
print (TownDescription)
你也应该尝试使用大写和小写的正确方法,虽然编译器并不关心,但它最终会让你的生活变得更轻松!