嵌套函数 - 参数缺少参数
Nested Functions - missing Argument for parameter
我一直在尝试在另一个函数中创建一个函数,其中 getPoolInfo 的输出将是 (Func1:Double, Func2:Double)。
我真的需要你们的帮助。
func getPoolInfo(PoolLength:Double, PoolWidth:Double, ShallowDepth:Double,DeepDepth:Double)->(Double,Double)
{
//To calculate the Area of the Pool
func Area(PoolLength:Double,PoolWidth:Double)-> Double
{
let area = PoolLength * PoolWidth
return area
}
//To calculate the Volume of the Pool
func poolVolume(PoolLength:Double, PoolWidth:Double, ShallowDepth:Double,DeepDepth:Double)->Double{
let area = PoolLength * PoolWidth
let avgDepth = ((ShallowDepth + DeepDepth) / 2)
let volume = area * avgDepth
return volume
}
return (Area(),poolVolume())
}
getPoolInfo(PoolLength: 12, PoolWidth: 6, ShallowDepth: 1, DeepDepth: 3)
Missing argument for parameter
改变
return (Area(),poolVolume())
至
return (Area(PoolLength:PoolLength,PoolWidth:PoolWidth),poolVolume(PoolLength:PoolLength, PoolWidth:PoolWidth, ShallowDepth:ShallowDepth,DeepDepth:DeepDepth))
我一直在尝试在另一个函数中创建一个函数,其中 getPoolInfo 的输出将是 (Func1:Double, Func2:Double)。
我真的需要你们的帮助。
func getPoolInfo(PoolLength:Double, PoolWidth:Double, ShallowDepth:Double,DeepDepth:Double)->(Double,Double)
{
//To calculate the Area of the Pool
func Area(PoolLength:Double,PoolWidth:Double)-> Double
{
let area = PoolLength * PoolWidth
return area
}
//To calculate the Volume of the Pool
func poolVolume(PoolLength:Double, PoolWidth:Double, ShallowDepth:Double,DeepDepth:Double)->Double{
let area = PoolLength * PoolWidth
let avgDepth = ((ShallowDepth + DeepDepth) / 2)
let volume = area * avgDepth
return volume
}
return (Area(),poolVolume())
}
getPoolInfo(PoolLength: 12, PoolWidth: 6, ShallowDepth: 1, DeepDepth: 3)
Missing argument for parameter
改变
return (Area(),poolVolume())
至
return (Area(PoolLength:PoolLength,PoolWidth:PoolWidth),poolVolume(PoolLength:PoolLength, PoolWidth:PoolWidth, ShallowDepth:ShallowDepth,DeepDepth:DeepDepth))