Skip to content

Commit

Permalink
sample does not modify the array - add readonly so that readonly arra…
Browse files Browse the repository at this point in the history
…ys can use sample
  • Loading branch information
jessegreenberg committed Jan 25, 2025
1 parent 5a811e6 commit 0582a36
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion js/Random.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default class Random {
* @param array - from which one element will be selected, must have at least one element
* @returns the selected element from the array
*/
public sample<T>( array: T[] ): T {
public sample<T>( array: readonly T[] ): T {
assert && assert( array.length > 0, 'Array should have at least 1 item.' );
const index = this.nextIntBetween( 0, array.length - 1 );
return array[ index ];
Expand Down

0 comments on commit 0582a36

Please sign in to comment.