Quiz 3: 2.2, Question 8 incorrect answer?

Question 8 in “Quiz 3: Check Your Understanding 2.2” asks:

"Which statement would successfully generate random numbers from the set: 1, 2, 3, 4, 5?"

To which the answer is Random.Range(1, 6)

However going from the documentation of the function, the min and max values are inclusive, which would mean the answer should actually be Random.Range(1, 5), surely?

They are only both inclusive if you are using the method overload which takes floats. If you scroll further down that documentation you will note that for integers, max is exclusive.

Aw dang, I knew by making this thread I was bound to be overlooking something!

Thanks for pointing that out!

1 Like

Don’t worry about it - your thread will help others too who will encounter the same issue, so actually, you’re a hero! :slight_smile:

Many of the methods provided in the Unity librabies have what are known as overloads / overloaded methods, you have probably already used another one of them actually, SceneManager.LoadScene for example, this can take either a string to represent the name of the scene to load, or an int which represents the build index of the scene to load.

Always scroll down through the documentation :slight_smile:

1 Like

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

Privacy & Terms