Is there a difference between these two styles?

Is there a reason to create the variable rather than just doing the random inside the array brackets [ ] ?

I ended up with this when i tried on my own:

case 1:
target = level1Words[Random.Range(0, level1Words.Length)];
break;

Is there something wrong with this or is it just a matter of style?
Since the “index” variable is only used one then destroyed, is there a reason to explicitly create a new variable?

Thanks in advance for helping out a beginner.

So I came onto the Forum at the point where we were instructed to discuss what we learned and what stumped us.
A minute later in the video Ben answered my question.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms