Skip to content

Commit

Permalink
Use assertMutuallyExclusiveOptions, see #103
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Aug 18, 2020
1 parent 5b58f75 commit 60312e5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions js/Random.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Mohamed Safi
*/

import assertMutuallyExclusiveOptions from '../../phet-core/js/assertMutuallyExclusiveOptions.js';
import merge from '../../phet-core/js/merge.js';
import dot from './dot.js';
import Range from './Range.js';
Expand All @@ -24,6 +25,10 @@ class Random {
* @param {Object} [options]
*/
constructor( options ) {

// If staticSeed and seed are both specified, there will be an assertion error.
assert && assertMutuallyExclusiveOptions( options, [ 'staticSeed' ], [ 'seed' ] );

options = merge( {

// {number|null} seed for the random number generator. When seed is null, Math.random() is used.
Expand All @@ -34,11 +39,6 @@ class Random {
staticSeed: false
}, options );

// If staticSeed and seed are both specified, there will be an assertion error.
if ( options.seed !== null && options.staticSeed ) {
assert && assert( false, 'cannot specify seed and staticSeed, use one or the other' );
}

// @private {number|null} initialized via setSeed below
this.seed = options.staticSeed ? window.phet.chipper.randomSeed : options.seed;

Expand Down

0 comments on commit 60312e5

Please sign in to comment.