
Dec. 13, 2019
7:32 a.m.
11.12.19 10:45, Steven D'Aprano пише:
The thing is, we're fooled by the close similarity of iteration over iterators and other iterables (sequences and containers). Destructive iteration and non-destructive iteration is a big difference. Utility functions like the proposed `first` that try to pretend there is no such difference are, I believe, a gotcha waiting to happen.
This is a good argument against first(). I was only -0 before, but now I am closer to strong -1. To use first() correctly you should know that it is barely a combination of iter() and next(), and if you know this, you no longer need first(). Using first() without knowing this is errorprone.