1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 19:58:49 +00:00

Add Random.CoinToss()

CoinToss() returns true if the next random number == 2, false otherwise
This commit is contained in:
Oliver Booth 2019-11-16 11:01:00 +00:00
parent 5da34dd762
commit 8c39914547
No known key found for this signature in database
GPG Key ID: 4B0992B2602C3778

View File

@ -12,6 +12,14 @@
/// </summary>
public static class RandomExtensions
{
/// <summary>
/// Returns either <see langword="true"/> or <see langword="false"/> based on <paramref name="random"/>'s next
/// generation.
/// </summary>
/// <param name="random">The <see cref="Random"/> instance.</param>
public static bool CoinToss(this Random random) =>
random.Next(2) == 0;
/// <summary>
/// Returns a random element from <paramref name="source"/> using the <see cref="Random"/> instance.
/// </summary>