Hello, welcome to the ATM tutorial or the swift programming tutorial series. And what we're going to look at is the function return statement returns demonstrate to end the function and return a value to the location the function was called take this simple math example that we're going to implement that allows us to send two numbers to function as them together and then returns it. It doesn't print line or anything like that within the function we'll be doing that ourselves because obviously, you're not want to print lines or maybe just want to get a value and that's usually what you want to do. So the general way is to put the keyword func so there's a function called print function or whatever your function name is. Inside my parameter, some number one and number two, end and then afterwards, you have to Specify the return type, basically, the type of data that the function is going to return.
So you have to put a dash greater than and then the desktop is an integer constant, multiply these two numbers together, put int. And now we can go ahead and implement that function, you might notice it's mon in that missing return if I'm expected to return it. If you have a function, and you have a return type, you have to return your call and not return. So you have to do return. And then wherever you return for this kind of point number one, my number two like is that and now we'll just call this and we'll call it within the premier line, or we'll do print function we'll specify two numbers five and six. I will get the result of 30.
Run it and we get the result of 30 If we were to just put this on some runner, you will still want fine obviously nothing printing, but because this function gets a value back, but nothing that can be done with it. But this is still valid because it is still calling the function. The return type is important because obviously, you don't want to put something like double in there in order to double likewise, you don't want to put something like in 10 days maybe if you do a thorough division, most likely if you're doing division, you will probably want to in decimal, you might want the other integer but just something to bear in mind. So yeah, that's it for this tutorial. In the next tutorial we're gonna look at classes. If you have any questions, feel free to message us at support at Sumner system code at UK.
The email will be in the description you can comment on this video or just directly messages via YouTube or the require links for source code will also be in the description. Thank you for watching and I hope you have a nice day.