As indicated in the header, I would like to know how to correctly check if the iterator is complete.
I did not find anything in the docs, but found something like this in the source:
iter.next.is_a? Iterator::Stop
Toy example:
a = "aδΈc" b = a.each_char puts b.next # a puts b.next # δΈputs b.next # c puts b.next # #<Iterator::Stop:0x8ccbff8> if b.next.is_a? Iterator::Stop puts "DONE" # successfully prints DONE end
This is right and right, or should I use a different way.
source share