0

About parameters in function

func rangeLength(start : Int, end : Int) -> Int{ return end - start } In this code above I used parameters end and start inside function. What will happen if I use another variables corresponding to start and end variables. Do I see any changes? For example func rangeLength(start : Int, end : Int) -> Int{ var startingPoint = 0 var endingPoint = 0 return startingPoint - endingPoint } Can anybody explain me ?

8th Nov 2018, 12:26 PM
Almaz
1 ответ
0
You get what the variables have: startingPoint = 0 endingPoint = 0 So: startingPoint - endingPoint = 0 - 0 So: 'return startingPoint - endingPoint' returns 0. Since no code uses the variables created by function parameters, nothing happens to these variables.
12th Nov 2018, 12:57 AM
Emerson Prado
Emerson Prado - avatar