namespace PkmnLib.Static.Utils;
///
/// Extension methods for .
///
public static class EnumerableHelpers
{
///
/// Returns all elements of the enumerable that are not null.
///
public static IEnumerable WhereNotNull(this IEnumerable enumerable) where T : class =>
enumerable.Where(x => x is not null)!;
///
/// Finds the index of a value in an enumerable. Returns -1 if the value is not found.
///
public static int IndexOf(this IEnumerable enumerable, T value)
{
var index = 0;
foreach (var item in enumerable)
{
if (item is null)
{
if (value is null)
return index;
continue;
}
if (item.Equals(value))
return index;
index++;
}
return -1;
}
}