【发布时间】:2016-02-19 17:07:09
【问题描述】:
我的任务是创建一个函数,该函数接受一个字符串和 int 的两个参数,该函数将返回一个字符串,该字符串将字符串参数重复 int 的次数。这是我想出的,但出现错误。顺便说一句,这是我在工作中使用的 CodeCardio,所以我无法在 Xcode 中对其进行测试(我的工作很糟糕并且使用 Windows)
func repeater(aString: String, withNumber: Int) -> String {
let repeatedString = String(count: withNumber, repeatedValue: aString)
return repeatedString
}
【问题讨论】:
标签: swift function swift2 repeat