Skip to content

mrstebo/IntegerExtensions.UpTo

Repository files navigation

IntegerExtensions.UpTo

A nicer read than Enumerable.Range.

Build status Coverage Status NuGet

This package is available via install the NuGet:

Install-Package IntegerExtensions.UpTo

Basic usage

This is a port of Ruby's upto method.

1.upto(5).to_a # [1, 2, 3, 4, 5]
2.upto(1).to_a # []

can be done like so,

1.UpTo(5).ToArray(); // [1, 2, 3, 4, 5]
2.UpTo(1).ToArray(); // []

UpTo returns an IEnumerable<T>, so you can easily use Linq methods with it.