openlogic / random-word

MIT License
27 stars 15 forks source link

How to recover from a StopIteration #3

Closed betesh closed 7 years ago

betesh commented 9 years ago

I am getting this error. It appears to be coming from RandomWord.nouns.next. I assume it means I reached the end of the list. what is the recommended way of recovering from it?

   StopIteration:
     iteration reached an end

I don't mind starting the list from the beginning again. It's just not clear how to do that.

toddthomas commented 7 years ago

There's no high-level API to reset the iterators, but this low-level technique used in the specs works fine:

RandomWord.instance_eval{ @nouns, @adjs = nil, nil }