我的Xcode Playground中有此代码。
//: Playground - noun: a place where people can play
import UIKit
func calcBMI(weight : Double, height : Double) -> String {
let bmi = weight / pow(height, 2)
let ShortenBMI = String(format: "%.2f", bmi)
var result = ""
if bmi > 25 {
result = "You're overweight."
}else if bmi > 18.5 {
result = "You're normal weight."
} else {
result = "You're underweight."
}
return "Your BMI is" + String(ShortenBMI) + " and " + result
}
var bmiResult = calcBMI(weight : 85, height : 1.8 )
print (bmiResult)
我不确定为什么我的Xcode似乎无法运行。
有没有办法检查出什么问题了?
我尝试重新启动Xcode并看到相同的结果。