1 00:00:00,330 --> 00:00:02,220 So how did you find that homework? 2 00:00:02,250 --> 00:00:06,990 Well, I mean, I gave you the function answer, really, you didn't have to think much about that, 3 00:00:07,200 --> 00:00:07,530 but. 4 00:00:08,780 --> 00:00:13,790 Her function homework, I don't think it's that necessary to to come up with these because you type 5 00:00:13,790 --> 00:00:16,900 it all the time when you're coding, you'll soon get into the swing of things. 6 00:00:17,390 --> 00:00:22,400 The tricky bit was to actually get those three numbers and multiply an array and I'm going to show you 7 00:00:22,400 --> 00:00:23,780 a basic way of doing it. 8 00:00:25,340 --> 00:00:30,560 We're going to have a VA return and this is going to contain the array of numbers that we're going to 9 00:00:30,560 --> 00:00:31,040 return. 10 00:00:35,420 --> 00:00:37,700 Which is an array of type int. 11 00:00:40,000 --> 00:00:43,900 And this at first is going to have no elements in it's just empty. 12 00:00:44,920 --> 00:00:49,450 They were going to say for a in the array that we're passing in. 13 00:00:52,030 --> 00:00:54,850 We're going to have return dot append. 14 00:01:00,380 --> 00:01:02,750 A times three. 15 00:01:05,590 --> 00:01:09,970 So that loop is going to go round and round, get each value, multiply it by three and shove it into 16 00:01:09,970 --> 00:01:14,170 the new array, and then finally we're going to return the return array. 17 00:01:15,240 --> 00:01:16,390 And that is literally it. 18 00:01:17,190 --> 00:01:18,930 So now we can call multiply. 19 00:01:19,890 --> 00:01:20,550 The array. 20 00:01:21,870 --> 00:01:24,780 Which will be, I don't know, let's try three, four or five. 21 00:01:27,110 --> 00:01:30,810 When we play that, we should get 15, 20, 25. 22 00:01:31,780 --> 00:01:39,460 But I mean, nine, 12, 15, because times three, not five, OK, so there we have it on the right 23 00:01:39,460 --> 00:01:40,090 hand side. 24 00:01:41,200 --> 00:01:44,440 Now, again, I want you to notice this word multiply. 25 00:01:44,560 --> 00:01:45,640 It's obvious what we're doing. 26 00:01:46,210 --> 00:01:49,810 If I give you an array of integers and I say, multiply this, everyone knows what that means. 27 00:01:51,130 --> 00:01:56,530 You don't need to write things like multiply this array of ints. 28 00:01:58,060 --> 00:01:59,600 Now, why don't I need to know that? 29 00:01:59,650 --> 00:02:00,070 Well. 30 00:02:02,320 --> 00:02:08,670 This array of integers is information that's actually communicated here, and I'll prove that to you. 31 00:02:10,230 --> 00:02:12,690 Because if we're typing, multiply. 32 00:02:13,740 --> 00:02:20,100 Look what comes up at the bottom of this pop up panel, we have multiply array array, which returns 33 00:02:20,100 --> 00:02:20,400 an array. 34 00:02:21,090 --> 00:02:28,500 So every time we are typing something in Swift, we get the signature that tells us what that item is 35 00:02:28,500 --> 00:02:33,000 doing and what it's doing it on and what it's going to give you back, if anything. 36 00:02:34,230 --> 00:02:36,820 So multiply is a perfectly valid word. 37 00:02:36,990 --> 00:02:39,900 Don't overdo the naming, but also don't underdo it. 38 00:02:40,410 --> 00:02:41,180 Do it just right.