Thanks for pointing this out. This is a bit of a subtle change between versions of SwiftUI. The simplest solution is to adjust the line as you did in your second example and change the calculation of numberRows to reflect the last item no longer being included in the range.
The next edition of the book will update to fix this issue.