feat: Adding Yield() enumerable extension, that turns an object into a single-item enumerable.

This commit is contained in:
Drew Tingen
2018-05-04 17:00:01 -04:00
parent 27f5fd0fe7
commit e43a7200c6

View File

@@ -801,6 +801,18 @@ namespace ICD.Common.Utils.Extensions
return output;
}
/// <summary>
/// Wraps this object instance into an IEnumerable<T>
/// consisting of a single item.
/// </summary>
/// <typeparam name="T"> Type of the object. </typeparam>
/// <param name="item"> The instance that will be wrapped. </param>
/// <returns> An IEnumerable&lt;T&gt; consisting of a single item. </returns>
public static IEnumerable<T> Yield<T>(this T item)
{
yield return item;
}
/// <summary>
/// Given a sequence [A, B, C] returns a sequence [[A, B], [B, C]]
/// </summary>