Iterators

GgsGgs
1 min read

Iterator can be defined in context -

For real life, as suffix ‘or‘ comes means it is the one who do the job of the word without ‘or‘ like here, iterator can be said as a person who do iterate .

But in programming it is not the same as here ,

Before iterators there comes iterable which means something that is ready to allow someone to do repeated task on it.Now when we do some repeated task on a thing we do it to get something in return. When u iterate/loop on someone we want the return but we cant just put our hand in it and take the return value so there comes iterator, any iterable thing when we start iterating throught it, it initiate with starting now as I said we can't put our hand to get the return value so iterator is like a claw which point towards the return value of a single interation/loop. Hence for an analogy iterators is a hand or a claw which is ready and pointing towards the iterates result and to make the claw work there comes next() which runs the claw and take the value,etc .

0
Subscribe to my newsletter

Read articles from Ggs directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ggs
Ggs