Skip to content

Instantly share code, notes, and snippets.

@Grabacr07

Grabacr07/fswallow.cs

Last active Aug 29, 2015
Embed
What would you like to do?
static class Extensions
{
public static IEnumerable<T[]> ふぁぼツバめそっど<T>(this IEnumerable<T> source, Func<T, bool> predicate)
{
var buffer = new List<T>();
foreach (var value in source)
{
if (predicate(value))
{
buffer.Add(value);
}
else if (buffer.Count > 0)
{
yield return buffer.ToArray();
buffer.Clear();
}
}
if (buffer.Count > 0)
{
yield return buffer.ToArray();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.