問題タブ [xrange]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - How does does xrange let you test membership?
Everyone seems to claim that xrange
returns a generator but it really is its own thing:
What I don't understand is how xrange
lets you check membership.
If this was a real generator, the second check would fail since we have already iterated through the 4.
There seems to be something special about xrange
that lets it do membership properly, as if it overrides __contains__
.