fix: Fixes invalid professions. (#1882)
This commit is contained in:
parent
e41d35d3d7
commit
0a07109cc1
4 changed files with 133 additions and 131 deletions
|
|
@ -745,6 +745,12 @@ public static class Utility
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T RandomList<T>(params T[] list) => list.RandomElement();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T RandomElement<T>(this ReadOnlySpan<T> list) => list.Length == 0 ? (T)default : list[Random(list.Length)];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T RandomElement<T>(this T[] list) => list.RandomElement(default);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T RandomElement<T>(this IList<T> list) => list.RandomElement(default);
|
||||
|
||||
|
|
@ -858,6 +864,10 @@ public static class Utility
|
|||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T RandomElement<T>(this T[] list, T valueIfZero) =>
|
||||
list.Length == 0 ? valueIfZero : list[Random(list.Length)];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T RandomElement<T>(this IList<T> list, T valueIfZero) =>
|
||||
list.Count == 0 ? valueIfZero : list[Random(list.Count)];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue