我对Swift非常陌生(Java体验)。当变量和值已经被声明时,我很困惑如何将一个变量传递给一个函数。如何将已经声明的变量传递给Swift中的函数?
func multiply(integer1: Int, integer2: Int) -> Int {
let returnValue = integer1 * integer2
return returnValue
}
var intX: Int = 5
var intY: Int = 10
print(multiply(intX, intY)) <- ?????????
为什么我们不能像以前声明的名称那样传递变量,就像在Java,C等中一样?由于我还在学习,请允许我的无意义。任何帮助表示赞赏!干杯!
您可能想阅读[定义和调用函数](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Functions.html#//apple_ref/doc/uid/TP40014097 -CH10-ID159) –