Hi I'm learning swift but I didn't understand the Return keyword which is used in the functions. Is there anybody who can explain me that ?
There are two kinds of functions — functions that you call because they do something, and functions that you call because they give you back some value. That second kind of function uses return to mark the value it sends back. For example, here's a function that takes a number and gives you back twice that value:
For more information, check out the Functions chapter of "The Swift Programming Language".
Code Block swift func twice(_ number: Int) -> Int { return number * 2 } let x = twice(7) print("Twice 7:") print(x)
For more information, check out the Functions chapter of "The Swift Programming Language".