mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
feat: Adding Yield() enumerable extension, that turns an object into a single-item enumerable.
This commit is contained in:
parent
27f5fd0fe7
commit
e43a7200c6
1 changed files with 12 additions and 0 deletions
|
|
@ -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<T> 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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue