Skip to content

Commit

Permalink
Merge f766827 into 8db4bef
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz authored Jun 25, 2023
2 parents 8db4bef + f766827 commit ba5c8c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions MoreLinq.Test/FillForwardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,18 @@ select line.Trim() into line
new { Continent = "Africa", Country = "Kenya", City = "Nairobi", Value = 901 },
}));
}

/// <summary>
/// Exercises bug reported in <see
/// href="https://github.com/morelinq/MoreLINQ/issues/999">issue #999</see>.
/// </summary>

[Test]
public void FillForwardWithNullFiller()
{
var input = new int?[] { null, 1, null, 2, null, 3, null };
var result = input.FillForward(x => x is not null);
result.AssertSequenceEqual(Enumerable.Repeat((int?)null, input.Length));
}
}
}
6 changes: 3 additions & 3 deletions MoreLinq/FillForward.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ static IEnumerable<T> FillForwardImpl<T>(IEnumerable<T> source, Func<T, bool> pr
{
if (predicate(item))
{
yield return seed is (true, { } someSeed)
yield return seed is (true, var theSeed)
? fillSelector != null
? fillSelector(item, someSeed)
: someSeed
? fillSelector(item, theSeed)
: theSeed
: item;
}
else
Expand Down

0 comments on commit ba5c8c5

Please sign in to comment.