This project is archived and is in readonly mode.

#1170 ✓wontfix

Number.random optional 3rd parameter to avoid consecutive duplicate numbers

Reported by raider5 | February 7th, 2011 @ 12:16 AM | in 1.3.1 (closed)


I know random is supposed to be random, but an optional 3rd parameter to avoid the same random number being generated in succession would be a nice addition e.g.

(getRandom would also need an optional parameter)

Example of its use:

We have an instance where we are randomly fading between elements in an element collection. When using the current getRandom it can sometimes appear as if no fade has taken place as getRandom has returned the same element in succession. It would be nice to pass in the current index so that a different random element is always returned.



Comments and changes to this ticket

  • Arian

    Arian February 8th, 2011 @ 12:17 AM

    • State changed from “new” to “wontfix”
    • Milestone set to 1.3.1
    • Assigned user set to “Arian”
    • Milestone order changed from “886” to “0”

    I would just implement it into your own number function and I think it's not something we should consider for mootools-core.

    I optimized your idea a bit:

  • raider5

    raider5 February 8th, 2011 @ 01:24 AM

    Hi Arian,

    Any reason for why you don't think it should be considered for core? I felt it would be a minimal change and that the example usage was quite valid.

    Could you point out where the optimisation is as I can't see it (



  • Arian

    Arian February 8th, 2011 @ 09:20 AM

    You're just subtracting 1 from the result if it's the 'current value', which isn't random. The reason why I think it shouldn't be added to core is first that core itself doesn't need it, and secondly because it's not a very common use-case in my opinion. The thing about mootools is that it doesn't add all stuff and might get bloated, but rather mootools is (or makes js even more) extensible. If you don't agree, please convince other devs :)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket