Generator functions equivalent in Java

后端 未结 7 872
后悔当初
后悔当初 2020-12-01 03:50

I would like to implement an Iterator in Java that behaves somewhat like the following generator function in Python:

def iterator(array):
   for         


        
7条回答
  •  我在风中等你
    2020-12-01 03:59

    The translation from Python-style generators to Java-style iterators can be automated. If you're willing to accept code generation in your build process, you might be interested in this prototype tool that does the translation for you:

    https://github.com/Calvin-L/gen2it

提交回复
热议问题