Is there a way to make a for loop that stalls and will only print the next element when next is called? It seems everything else runs smoothly, at this points I’m typing because it won’t let me post my question unless I explain more. I feel my problem is quite direct though.
Share
If you really need a next() method, you can create one inside your Fibonacci.
Create a global variable
then your next() will look as follows
Then you can use next() function to print next element.