扩展双轮斯威夫特3
问题描述:
答
你忘了一个括号:应该是rounded()
而不是rounded
:
extension Double {
func roundToPlaces(places:Int) -> Double {
let divisor = pow(10.0, Double(places))
return (self * divisor).rounded()/divisor
}
}
哦,对了。万分感谢! –