Skip to content

Commit f09050d

Browse files
leandromohatifaziz
authored andcommitted
Simplify looping condition in Sequence operator
1 parent 66d3458 commit f09050d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

MoreLinq/Sequence.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@ public static IEnumerable<int> Sequence(int start, int stop)
6565

6666
public static IEnumerable<int> Sequence(int start, int stop, int step)
6767
{
68-
var initial = start;
6968
long current = start;
7069

71-
while (step >= 0 ? stop >= current && initial <= current
72-
: stop <= current && initial >= current)
70+
while (step >= 0 ? stop >= current
71+
: stop <= current)
7372
{
7473
yield return (int)current;
7574
current = current + step;

0 commit comments

Comments
 (0)