Difference between two function calls - Swift -
what difference between these 2 swift functions. don't quite understand it. know 2 different functions have different parameter structures.
func addtwointegers(first x:int, second y:int) -> int{ return x + y } func multiplytwointegers(x:int, y:int) -> int{ return x * y }
the difference between 2 functions evident if use them inside of swift’s playground. first function uses external naming parameters allow see name of parameters in kind of objective-c style fashion. example, when call addtwointegers
, able call while passing in arguments addtwointegers(first: x, second: y)
. second function not use external naming parameters can call passing in arguments such multiplytwointegers(2,2)
copy code xcode’s playground.
func addtwointegers(first x:int, second y:int) -> int{ return x + y } func multiplytwointegers(x:int, y:int) -> int{ return x * y } var x = addtwointegers(first: 10, second: 10) var y = multiplytwointegers(2, 2) println(x) println(y)
Comments
Post a Comment