What must I do in order to be able to return an Iterator from a method/class ? How would one add that trait to a class?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can extend Iterator, which will require that you implement the
nextandhasNextmethods:But, you will get more flexibility if you extend Iterable, which requires you implement
elements(oriteratorin 2.8):A common idiom seems to be to expose an iterator to some private collection, like this: