Placeholder Image

Subtitles section Play video

  • Hey, guys, what we're gonna do today is go over and exercise on functions within mark prices.

  • Eyeless 10 and Swift through Unity Course it is section to lecture 20 as of this date, and it's exercising function.

  • So normally I put this which I will put this into my idol journey.

  • But I know there's some people who are just searching, you know, maybe they want to follow along with someone else doing this exact exercise.

  • So I figured I'd make it a standalone video as well.

  • But if you want to see me go through like all of Section two, I'm going to make a two separate videos on that already make made quite a few going through, You know, different levels of Iowa's development, learning it storyboard and and things like that so you can check that out on my channel.

  • But I figured I make this a seven video for for all those who just want to see this.

  • So let's get to that.

  • So the first thing to do create a new, extra playground done creative function named Ad that takes two parameters of type double and returns to some of the two numbers.

  • So we want to create a function and add.

  • That's all right.

  • Ad.

  • We could name these, uh, number one.

  • And then it said it wants to be a double.

  • We do it like that.

  • And then we do know too.

  • You could name whatever you want, but that's just what I'm gonna name this for sake of argument and then within it.

  • What did it want us to do?

  • I want us to return some of the two numbers so we could do return number one.

  • Plus number two on you.

  • Don't call it anything.

  • So let's be right, Right?

  • No, maybe not.

  • Maybe not.

  • I would have to send this over like this.

  • Make that a double like that, that you were great.

  • I don't see that you're turning anything.

  • Let's let's go into the next deal.

  • Sometimes there's a slow for me, so I just have to keep it moving, and then I'll come back to you in a bit.

  • So that was questioned to question one question to now courses through creative function names attract that takes two parameters of type into so integers and returns difference of the two numbers.

  • So, basically, just don't say anything but subtracting way just return.

  • It seems that weighs last time, but subtracting.

  • But what do you want us to do?

  • Returns a difference of the two numbers, So Oh, that's right.

  • What we didn't do is a sign numbers to the actual, very correct.

  • I'm still having trouble with this reader over here because it's just this hell, a playground.

  • But it's not.

  • Hello, playground.

  • So what we're gonna do is we're gonna eggs out of this and then and then I'm gonna pay you back in.

  • Hopefully that'll fix it.

  • The notion had I don't think you have anything because we haven't cleared number one to be any type of number.

  • Suffered a double.

  • So basically, the next thing we do is it seems like thing, but we multiply floats and then after that, we're gonna divide double.

  • So let's just hurry up and do that already.

  • So because it's really not that difficult, No, we're gonna do next.

  • Is all those functions all this?

  • What does it say?

  • All of this functions in past different values into the parameters and sure they're producing the correct results.

  • This isn't miss.

  • I don't know.

  • This may be a misprint.

  • but basically we're giving all these numbers.

  • Okay, so it looks like it wants is to assign these.

  • It wants us to reference our call these functions into a situation where we're actually declaring the numbers so we can use of our or let just do it, make it nice and neat.

  • Let, uh I don't think I can use ad Duke let plus on thes air doubles.

  • So, actually, just not do that.

  • Let's do 3.3 e.

  • I think I have to put equal sign there.

  • Maybe.

  • Yeah.

  • Okay.

  • And now it goes back up into This is the last thing that you wanted them to equal within this function.

  • We just did it with all let minus make number two equal.

  • Seven.

  • We'll see that this doesn't work because it needs to be an interview.

  • Integer to an integer.

  • So if we take these out, it works.

  • Eight minus seven.

  • A minus three.

  • Even if we put a double over here, it won't work because obviously there declared to be an integer hasn't changed yet till I get out of there.

  • As you can see, there's errors era here.

  • It just didn't change her here.

  • Three folk can only hold like so many bites.

  • It's only it's only so many bites worth, while a double is a lot bigger than afloat.

  • So normally they say, use use a double.

  • Some people would like to say, Oh, no, I want to use a float because it's going to use the last memory Well, it's not worth in the long run.

  • I mean, if you need a change, that means you'd have to go back and change the float.

  • And the only reason you need to do that is if there's an error in your code.

  • So So I think that's it.

  • They just want us to throw values in there, make sure worked each and every way, major, the double worked, right?

  • Our major first of all, major, that our function works right, major, that we declared it correctly in order for you to doubles, to come on as a double.

  • And in order for us to only be allowed to put in doubles, there's well into your float and double again.

  • So that's the end of this exercise.

  • Swift.

  • Three functions.

  • I hope you guys enjoyed it.

  • You haven't checked out my journey yet.

  • Be sure to do so if you wanna, you know, get on this journey with me and I'll support you guys while you'll support me and it'll it'll help us get closer to our goal, our end goal.

  • And that's to be in Iowa's developer, one way or another, so I hope you enjoyed it have going.

Hey, guys, what we're gonna do today is go over and exercise on functions within mark prices.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it