mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:25:43 +00:00
🔨 Call OneOf() overload to reduce duplication
This commit is contained in:
parent
8c39914547
commit
ae4f7f7b38
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -28,7 +29,7 @@
|
|||||||
/// <param name="source">The collection to draw from.</param>
|
/// <param name="source">The collection to draw from.</param>
|
||||||
/// <returns>Returns a random element of type <see cref="T"/> from <paramref name="source"/>.</returns>
|
/// <returns>Returns a random element of type <see cref="T"/> from <paramref name="source"/>.</returns>
|
||||||
public static T OneOf<T>(this Random random, params T[] source) =>
|
public static T OneOf<T>(this Random random, params T[] source) =>
|
||||||
source[random.Next(source.Length)];
|
source.ToList().OneOf(random);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a random element from <paramref name="source"/> using the <see cref="Random"/> instance.
|
/// Returns a random element from <paramref name="source"/> using the <see cref="Random"/> instance.
|
||||||
|
Loading…
Reference in New Issue
Block a user