mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
feat: Adding Yield() enumerable extension, that turns an object into a single-item enumerable.
This commit is contained in:
@@ -801,6 +801,18 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
return output;
|
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<T> consisting of a single item. </returns>
|
||||||
|
public static IEnumerable<T> Yield<T>(this T item)
|
||||||
|
{
|
||||||
|
yield return item;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Given a sequence [A, B, C] returns a sequence [[A, B], [B, C]]
|
/// Given a sequence [A, B, C] returns a sequence [[A, B], [B, C]]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user