la-yumba / functional-csharp-code

Code samples for Functional Programming in C#

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code errors

lctk opened this issue · comments

commented

In Chapter 10, the code is
`var startOfPeriod = new DateTime(year, month, 1);
var endOfPeriod = startOfPeriod.AddMonths(1);

     var eventsBeforePeriod = events
        .TakeWhile(e => e.Timestamp < startOfPeriod);
     var eventsDuringPeriod = events
        .SkipWhile(e => e.Timestamp < startOfPeriod)
        .TakeWhile(e => endOfPeriod < e.Timestamp);`

I think the correct code should be
var eventsDuringPeriod = events .SkipWhile(e => e.Timestamp < startOfPeriod) .TakeWhile(e => e.Timestamp < endOfPeriod );

yes, that's correct