JavaScript, for better or worse, has a much smaller standard library than what .NET developers are used to with the base class library (BCL). The JavaScript community has made many attempts to build a standard library, and I’m sure some of them are great. As I was scanning the options, I came across a fascinating method named
intersperse
, which “inserts a separator between the elements of its list argument”.
In this post, I’ll implement the same method in C# as an extension method on the IEnumerable
interface.