So did you think long and hard about that?
Well.
You probably came up with something like this, you had three integers, whatever they are, seven,
four, three in my case, you said if I want to multiply them together, I'm just going to go to my
new array and I'm going to get Elements zero way to multiply it by my new array.
Element one.
And multiply it by my new array.
Element to now, I'm sorry if I forgot to mention that the index is of a actually increment upwards
012.
I don't think actually you said that, but I would guess that maybe that was implied.
I don't know.
And of course, if we run that we get seven times four times three, which is apparently 80 for.
Now, before the break, I told you that I want you to think logically about these things, this is
bad code.
Can you guess why it's bad code?
Because an array could be any size.
Usually you'll get something like an array from your database, from your server, and you don't actually
know how big it is.
Or maybe you do.
You know, the 50 items are coming from your server to play music to the end user.
But what if someone changes that to 40 items to reduce load on the server?
What do you do then?
Well, your code is wrong if you have 50 items that you multiply.
And besides that, imagine repeating that, what, 15, 16 times?
You don't want to do that.
Do you say what I was trying to get across to you and I'm not going to give you the solution here?
It'll become it'll become pretty obvious what the solution is as you proceed through this course.
But what I want you to think about is, is this unsustainable?
And if it is, how would I go about fixing this?
I'm going to give you the tools to fix it in a couple of lectures time when we talk about control,
flow effects and statements like that, that will solve these problems for us.
But I just wanted you to think about the dangers that lurk when you just have a throwaway piece of code
moment and say, I'll just do it like this.
And you don't realize that in the future that's going to cause you a world of pain anyway.
That's enough of me bleating on about this onto the next one.