mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 19:48:46 +00:00
✨ Add Random.CoinToss()
CoinToss() returns true if the next random number == 2, false otherwise
This commit is contained in:
parent
5da34dd762
commit
8c39914547
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user