# Bad comment for unity's function "int" Random.Range.

**URL:** https://discussions.unity.com/t/bad-comment-for-unitys-function-int-random-range/613060
**Category:** Documentation
**Tags:** Unity-Documentation
**Created:** [January 18, 2016, 9:17am UTC](https://discussions.unity.com/t/bad-comment-for-unitys-function-int-random-range/613060 "2016-01-18T09:17:14Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![eyalm](https://avatars.discourse-cdn.com/v4/letter/e/8e7dd6/32.png) [@eyalm](https://discussions.unity.com/u/eyalm)
#### Post date: [January 18, 2016, 9:17am UTC](https://discussions.unity.com/t/bad-comment-for-unitys-function-int-random-range/613060/1 "2016-01-18T09:17:14Z")

</div>

In untiy:  
//  
// Summary:  
// Returns a random float number between and min [inclusive] and max [inclusive]  
// (Read Only).  
public static int Range(int min, int max);

in documents:

> **[Unity - Scripting API: Random.Range](https://docs.unity3d.com/ScriptReference/Random.Range.html)**

Returns a random float number between and min [inclusive] and max [inclusive] (Read Only).

The true one is the document’s version, I’v checked.

---

<div class="post-metadata">

### Author: ![duck](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/duck/32/477465_2.png) [@duck](https://discussions.unity.com/u/duck)
#### Post date: [January 19, 2016, 4:51pm UTC](https://discussions.unity.com/t/bad-comment-for-unitys-function-int-random-range/613060/2 "2016-01-19T16:51:34Z")

</div>

There are two different versions of this function.

The version which accepts float values is inclusive for both parameters.

The version which accepts int values is exclusive on its max value (which maxes it convenient for referencing a random index of an array).

eg:

**myArray[Random.Range(0,myArray.Length)]**

---

<div class="post-metadata">

### Author: ![eyalm](https://avatars.discourse-cdn.com/v4/letter/e/8e7dd6/32.png) [@eyalm](https://discussions.unity.com/u/eyalm)
#### Post date: [February 4, 2016, 2:24pm UTC](https://discussions.unity.com/t/bad-comment-for-unitys-function-int-random-range/613060/3 "2016-02-04T14:24:50Z")

</div>

> [@duck](#):
>
> There are two different versions of this function.
> 
> The version which accepts float values is inclusive for both parameters.
> 
> The version which accepts int values is exclusive on its max value (which maxes it convenient for referencing a random index of an array).
> 
> eg:
> 
> **myArray[Random.Range(0,myArray.Length)]**

I’m talking only on the int version ( look at the code example i’v posted ).

---

<div class="post-metadata">

### Author: ![duck](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/duck/32/477465_2.png) [@duck](https://discussions.unity.com/u/duck)
#### Post date: [February 8, 2016, 12:49pm UTC](https://discussions.unity.com/t/bad-comment-for-unitys-function-int-random-range/613060/4 "2016-02-08T12:49:12Z")

</div>

I still can’t work out where you’re seeing the bad version. You seem to be saying the docs are right, but there is some example code somewhere that is wrong? Where is it? Let me know and I’ll fix it! 🙂

---

<div class="post-metadata">

### Author: ![eyalm](https://avatars.discourse-cdn.com/v4/letter/e/8e7dd6/32.png) [@eyalm](https://discussions.unity.com/u/eyalm)
#### Post date: [February 10, 2016, 12:18pm UTC](https://discussions.unity.com/t/bad-comment-for-unitys-function-int-random-range/613060/5 "2016-02-10T12:18:51Z")

</div>

You can see the mistake when opening visual studio/mono developer and right click on the Random.Range function and pick “Go To Definition”.  
There you will see the functions with their comments.

---

<div class="post-metadata">

### Author: ![duck](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/duck/32/477465_2.png) [@duck](https://discussions.unity.com/u/duck)
#### Post date: [February 16, 2016, 10:42am UTC](https://discussions.unity.com/t/bad-comment-for-unitys-function-int-random-range/613060/6 "2016-02-16T10:42:20Z")

</div>

Oooh I see, looks like that’s actually coming from the Unity sourcecode itself! I’ll see what I can do.

---

<div class="post-metadata">

### Author: ![duck](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/duck/32/477465_2.png) [@duck](https://discussions.unity.com/u/duck)
#### Post date: [February 16, 2016, 11:15am UTC](https://discussions.unity.com/t/bad-comment-for-unitys-function-int-random-range/613060/7 "2016-02-16T11:15:49Z")

</div>

Which version of Unity are you seeing this in? I just had a look in 5.3 and I’m seeing a different (correct) version, and I also notice that the commands marked ‘obsolete’ in mine aren’t marked like that in yours, so perhaps you’re looking at an older version of unity?

Here’s what mine looks like:

---

<div class="post-metadata">

### Author: ![Chris\_TerraTech](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/chris_terratech/32/314910_2.png) [@Chris\_TerraTech](https://discussions.unity.com/u/Chris_TerraTech)
#### Post date: [May 16, 2016, 1:54pm UTC](https://discussions.unity.com/t/bad-comment-for-unitys-function-int-random-range/613060/8 "2016-05-16T13:54:34Z")

</div>

Sorry for the thread necro, but I’m also seeing this in 5.3.4f1.
